diff --git a/CHANGELOG.md b/CHANGELOG.md index 948c4b4..92ba3e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,12 @@ # Change Log - ## [1.2.0][v120] - Not released yet -* Introduce set_color_custom function that prompts can define to customize *fish_color_* variables. The user current color palette is saved to $fisher_config/fish_colors and restored when the prompt is disabled #144. +* Introduce set_color_custom function that prompts can define to customize *fish_color_* variables. The current color palette is saved to $fisher_config/fish_colors and restored when the prompt is disabled / uninstalled #144. -* Fix bug where fisher_path_is_prompt was not picking up prompts that define its functions inside a functions directory. #155. +* Fix a bug where fisher_path_is_prompt was not picking up prompts that define functions inside a functions directory. #155. -* Add test stubs for missing test cases. We'll get around those eventually. +* Add support to read oh-my-fish bundle file package declarations. ## [1.1.0][v110] - 2016-03-02 diff --git a/functions/__fisher_config_color_reset.fish b/functions/__fisher_config_color_reset.fish index 00a0d9a..e570d5a 100644 --- a/functions/__fisher_config_color_reset.fish +++ b/functions/__fisher_config_color_reset.fish @@ -1,5 +1,5 @@ function __fisher_config_color_reset - if test ! -f "$fisher_config/fish_colors" + if test ! -f "$path" set -U fish_color_normal normal set -U fish_color_command 005fd7 purple set -U fish_color_param 00afff cyan @@ -8,8 +8,10 @@ function __fisher_config_color_reset set -U fish_color_error red --bold set -U fish_color_escape cyan set -U fish_color_operator cyan + set -U fish_color_end green set -U fish_color_quote brown set -U fish_color_autosuggestion 555 yellow + set -U fish_color_user green set -U fish_color_valid_path --underline set -U fish_color_cwd green set -U fish_color_cwd_root red @@ -21,35 +23,39 @@ function __fisher_config_color_reset set -U fish_pager_color_description 555 yellow set -U fish_pager_color_progress cyan set -U fish_color_history_current cyan + set -U fish_color_host normal return end set -l IFS \n - read -laz fish_colors < $fisher_config/fish_colors + read -laz fish_colors < $path - set -U fish_color_normal (echo $fish_colors[1] | tr " " \n) - set -U fish_color_command (echo $fish_colors[2] | tr " " \n) - set -U fish_color_param (echo $fish_colors[3] | tr " " \n) - set -U fish_color_redirection (echo $fish_colors[4] | tr " " \n) - set -U fish_color_comment (echo $fish_colors[5] | tr " " \n) - set -U fish_color_error (echo $fish_colors[6] | tr " " \n) - set -U fish_color_escape (echo $fish_colors[7] | tr " " \n) - set -U fish_color_operator (echo $fish_colors[8] | tr " " \n) - set -U fish_color_quote (echo $fish_colors[9] | tr " " \n) - set -U fish_color_autosuggestion (echo $fish_colors[10] | tr " " \n) - set -U fish_color_valid_path (echo $fish_colors[11] | tr " " \n) - set -U fish_color_cwd (echo $fish_colors[12] | tr " " \n) - set -U fish_color_cwd_root (echo $fish_colors[13] | tr " " \n) - set -U fish_color_match (echo $fish_colors[14] | tr " " \n) - set -U fish_color_search_match (echo $fish_colors[15] | tr " " \n) - set -U fish_color_selection (echo $fish_colors[16] | tr " " \n) - set -U fish_pager_color_prefix (echo $fish_colors[17] | tr " " \n) - set -U fish_pager_color_completion (echo $fish_colors[18] | tr " " \n) - set -U fish_pager_color_description (echo $fish_colors[19] | tr " " \n) - set -U fish_pager_color_progress (echo $fish_colors[20] | tr " " \n) - set -U fish_color_history_current (echo $fish_colors[21] | tr " " \n) + set -U fish_color_normal (echo $fish_colors[1] | tr " " \n) + set -U fish_color_command (echo $fish_colors[2] | tr " " \n) + set -U fish_color_param (echo $fish_colors[3] | tr " " \n) + set -U fish_color_redirection (echo $fish_colors[4] | tr " " \n) + set -U fish_color_comment (echo $fish_colors[5] | tr " " \n) + set -U fish_color_error (echo $fish_colors[6] | tr " " \n) + set -U fish_color_escape (echo $fish_colors[7] | tr " " \n) + set -U fish_color_operator (echo $fish_colors[8] | tr " " \n) + set -U fish_color_end (echo $fish_colors[9] | tr " " \n) + set -U fish_color_quote (echo $fish_colors[10] | tr " " \n) + set -U fish_color_autosuggestion (echo $fish_colors[11] | tr " " \n) + set -U fish_color_user (echo $fish_colors[12] | tr " " \n) + set -U fish_color_valid_path (echo $fish_colors[13] | tr " " \n) + set -U fish_color_cwd (echo $fish_colors[14] | tr " " \n) + set -U fish_color_cwd_root (echo $fish_colors[15] | tr " " \n) + set -U fish_color_match (echo $fish_colors[16] | tr " " \n) + set -U fish_color_search_match (echo $fish_colors[17] | tr " " \n) + set -U fish_color_selection (echo $fish_colors[18] | tr " " \n) + set -U fish_pager_color_prefix (echo $fish_colors[19] | tr " " \n) + set -U fish_pager_color_completion (echo $fish_colors[20] | tr " " \n) + set -U fish_pager_color_description (echo $fish_colors[21] | tr " " \n) + set -U fish_pager_color_progress (echo $fish_colors[22] | tr " " \n) + set -U fish_color_history_current (echo $fish_colors[23] | tr " " \n) + set -U fish_color_host (echo $fish_colors[24] | tr " " \n) - rm -f $fisher_config/fish_colors + rm -f $path end diff --git a/functions/__fisher_config_color_save.fish b/functions/__fisher_config_color_save.fish index b78311b..8ae849a 100644 --- a/functions/__fisher_config_color_save.fish +++ b/functions/__fisher_config_color_save.fish @@ -1,26 +1,31 @@ -function __fisher_config_color_save - if test ! -f "$fisher_config/fish_colors" - printf "%s\n" \ - "$fish_color_normal" \ - "$fish_color_command" \ - "$fish_color_param" \ - "$fish_color_redirection" \ - "$fish_color_comment" \ - "$fish_color_error" \ - "$fish_color_escape" \ - "$fish_color_operator" \ - "$fish_color_quote" \ - "$fish_color_autosuggestion" \ - "$fish_color_valid_path" \ - "$fish_color_cwd" \ - "$fish_color_cwd_root" \ - "$fish_color_match" \ - "$fish_color_search_match" \ - "$fish_color_selection" \ - "$fish_pager_color_prefix" \ - "$fish_pager_color_completion" \ - "$fish_pager_color_description" \ - "$fish_pager_color_progress" \ - "$fish_color_history_current" > "$fisher_config/fish_colors" +function __fisher_config_color_save -a path + if test -f "$path" + return 1 end + + printf "%s\n" \ + "$fish_color_normal" \ + "$fish_color_command" \ + "$fish_color_param" \ + "$fish_color_redirection" \ + "$fish_color_comment" \ + "$fish_color_error" \ + "$fish_color_escape" \ + "$fish_color_operator" \ + "$fish_color_end" \ + "$fish_color_quote" \ + "$fish_color_autosuggestion" \ + "$fish_color_user" \ + "$fish_color_valid_path" \ + "$fish_color_cwd" \ + "$fish_color_cwd_root" \ + "$fish_color_match" \ + "$fish_color_search_match" \ + "$fish_color_selection" \ + "$fish_pager_color_prefix" \ + "$fish_pager_color_completion" \ + "$fish_pager_color_description" \ + "$fish_pager_color_progress" \ + "$fish_color_history_current" \ + "$fish_color_host" > "$path" end diff --git a/functions/__fisher_file.fish b/functions/__fisher_file.fish index 0e62c8b..b92d161 100644 --- a/functions/__fisher_file.fish +++ b/functions/__fisher_file.fish @@ -1,5 +1,11 @@ function __fisher_file awk -v FS=\t ' + /^[ \t]*package / { + gsub("^[ \t]*package ", "https://github.com/oh-my-fish/plugin-") + printf("%s\n", $0) + next + } + /@http/ { gsub("@.*$", "", $1) } diff --git a/functions/__fisher_plugin_disable.fish b/functions/__fisher_plugin_disable.fish index 7b7459c..406ab9c 100644 --- a/functions/__fisher_plugin_disable.fish +++ b/functions/__fisher_plugin_disable.fish @@ -14,7 +14,7 @@ function __fisher_plugin_disable -a plugin path option __fisher_plugin_unlink $fisher_config/$target $name if test "$name" = set_color_custom - __fisher_config_color_reset + __fisher_config_color_reset "$fisher_config/fish_colors" end end end diff --git a/functions/__fisher_plugin_enable.fish b/functions/__fisher_plugin_enable.fish index 9fc3d2d..392b640 100644 --- a/functions/__fisher_plugin_enable.fish +++ b/functions/__fisher_plugin_enable.fish @@ -37,7 +37,8 @@ function __fisher_plugin_enable -a plugin path __fisher_plugin_source $plugin $fisher_config/$target if test "$name" = set_color_custom - __fisher_config_color_save + debug "Colors" + __fisher_config_color_save "$fisher_config/fish_colors" set_color_custom end end diff --git a/functions/fisher_search.fish b/functions/fisher_search.fish index 534e81e..6da461f 100644 --- a/functions/fisher_search.fish +++ b/functions/fisher_search.fish @@ -129,8 +129,8 @@ function fisher_search -d "Search plugin index" end set -l color_name (set_color $fish_color_command) - set -l color_url (set_color $fish_color_cwd -u) - set -l color_tag (set_color $fish_color_cwd) + set -l color_url (set_color $fish_color_quote -u) + set -l color_tag (set_color $fish_color_quote) set -l color_weak (set_color white) set -l color_author (set_color -u) set -l color_normal (set_color $fish_color_normal) diff --git a/test/config-color-save.fish b/test/config-color-save.fish index 831d089..fe5e4c1 100644 --- a/test/config-color-save.fish +++ b/test/config-color-save.fish @@ -1,3 +1,24 @@ -test "$TESTNAME - Todo" - -z "" +set -l path $DIRNAME/.t-$TESTNAME-(random) + +function -S setup + mkdir -p $path/{foo,bar} + + __fisher_config_color_save $path/foo/fish_colors + + touch $path/bar/fish_colors +end + +function -S teardown + rm -rf $path +end + +test "$TESTNAME - Create fish_colors in path" + -s $path/foo/fish_colors +end + +test "$TESTNAME - Create fish_colors in path" + 1 = ( + __fisher_config_color_save $path/bar/fish_colors + echo $status + ) end diff --git a/test/fixtures/manifest/fishfile b/test/fixtures/manifest/fishfile index 34950e5..a77e339 100644 --- a/test/fixtures/manifest/fishfile +++ b/test/fixtures/manifest/fishfile @@ -37,3 +37,5 @@ https://github.com/quux/fisher-thud # may include other files too, but there should be only *one* fish file. gisty@https://gist.github.com/xxxx + +package mof diff --git a/test/fixtures/manifest/fishfile-no-comments b/test/fixtures/manifest/fishfile-no-comments index 0c11b42..c09ac71 100644 --- a/test/fixtures/manifest/fishfile-no-comments +++ b/test/fixtures/manifest/fishfile-no-comments @@ -8,3 +8,4 @@ https://github.com/quux/fish-fred https://github.com/quux/fisher-thud /Users/fisherboy/Projects/fisherman/plugins/chomp gisty@https://gist.github.com/xxxx +package mof diff --git a/test/fixtures/manifest/fishfile-parsed b/test/fixtures/manifest/fishfile-parsed index 2c6fd60..a92ce80 100644 --- a/test/fixtures/manifest/fishfile-parsed +++ b/test/fixtures/manifest/fishfile-parsed @@ -8,3 +8,4 @@ https://github.com/quux/fish-fred https://github.com/quux/fisher-thud /Users/fisherboy/Projects/fisherman/plugins/chomp gisty +https://github.com/oh-my-fish/plugin-mof diff --git a/test/list-fishfile.fish b/test/list-fishfile.fish index d29558a..b7c0958 100644 --- a/test/list-fishfile.fish +++ b/test/list-fishfile.fish @@ -1,11 +1,9 @@ set -l manifest $DIRNAME/fixtures/manifest -set -l plugins foo bar baz norf zerg quux hoge foobar fred thud chomp boo loo gisty +set -l plugins foo bar baz quux hoge foobar fred thud chomp gisty mof test "$TESTNAME - Parse fishfile and retrieve plugin names with fisher list fishfile" - - # We use fisher list to parse and then extract the plugin's name - # as it will be used by the CLI. See also `test/name.fish`. - - (fisher list $manifest/fishfile) = $plugins + $plugins = ( + fisher list $manifest/fishfile + ) end