From cde155debd0a1ea1c08053ed698f216121e92b55 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Sat, 28 May 2016 18:09:53 +0900 Subject: [PATCH] Introduce fish_path. Fix #301. --- README.md | 20 +++++++++++++++----- fisher.fish | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7304aca..35eb2bc 100644 --- a/README.md +++ b/README.md @@ -131,13 +131,23 @@ end Yes. +### Where does fisherman put stuff? + +The configuration and cache are saved to ~/.config/fisherman and ~/.cache/fisherman respectively. + +The fishfile and plugins are saved to ~/.config/fish by default. + +To customize this location: + +```fish +set fish_path ~/my/path +``` + ### What is a fishfile and how do I use it? -The fishfile ~/.config/fish/fishfile lists what plugins you've installed. +The fishfile lists what you've installed, and it's automatically updated as you install / remove plugins. -This file is updated automatically as you install / remove plugins. You can also edit this file and run `fisher` to commit changes. - -This mechanism only installs plugins and missing dependencies. To remove plugins, use `fisher rm`. +If you prefer, you can edit this file and run `fisher` to install missing plugins and dependencies. ### What is a plugin? @@ -151,4 +161,4 @@ A plugin is: ### How can I list plugins as dependencies to my plugin? -Create a new fishfile file at the root level of your project and write the plugin URL such as *github.com/owner/repo*. +Create a new fishfile at the root level of your project and write the plugin URL such as *github.com/owner/repo*. diff --git a/fisher.fish b/fisher.fish index b3e1567..a225dad 100644 --- a/fisher.fish +++ b/fisher.fish @@ -70,8 +70,12 @@ function $fisher_cmd_name -d "fish plugin manager" set -g fisher_cache "$cache_home/fisherman" end + if test -z "$fish_path" + set -g fish_path "$fish_config" + end + if test -z "$fisher_file" - set -g fisher_file "$fish_config/fishfile" + set -g fisher_file "$fish_path/fishfile" end switch "$argv[1]" @@ -88,7 +92,7 @@ function $fisher_cmd_name -d "fish plugin manager" return end - command mkdir -p "$fish_config/"{conf.d,functions,completions} "$fisher_config" "$fisher_cache" + command mkdir -p {"$fish_path","$fish_config"}/{conf.d,functions,completions} "$fisher_config" "$fisher_cache" or return 1 set -l completions "$fish_config/completions/$fisher_cmd_name.fish" @@ -748,10 +752,10 @@ function __fisher_plugin_enable -a path set base "$plugin_name.$base" end - set -l target "$fish_config/$dir/$base" + set -l target "$fish_path/$dir/$base" if test -e "$target" -a ! -L "$target" - set -l backup_target "$fish_config/$dir/copy-$base" + set -l backup_target "$fish_path/$dir/copy-$base" __fisher_log info "Backup &$base&" "$__fisher_stderr" @@ -763,8 +767,8 @@ function __fisher_plugin_enable -a path builtin source "$target" ^ /dev/null if test "$base" = "set_color_custom.fish" - if test ! -s "$fish_config/fish_colors" - __fisher_print_fish_colors > "$fish_config/fish_colors" + if test ! -s "$fish_path/fish_colors" + __fisher_print_fish_colors > "$fish_path/fish_colors" end set_color_custom @@ -773,17 +777,17 @@ function __fisher_plugin_enable -a path for file in $path/{functions/,}*.{py,awk} set -l base (basename "$file") - command ln -sf "$file" "$fish_config/functions/$base" + command ln -sf "$file" "$fish_path/functions/$base" end for file in $path/conf.d/*.{py,awk} set -l base (basename "$file") - command ln -sf "$file" "$fish_config/conf.d/$base" + command ln -sf "$file" "$fish_path/conf.d/$base" end for file in $path/conf.d/*.fish set -l base (basename "$file") - set -l target "$fish_config/conf.d/$base" + set -l target "$fish_path/conf.d/$base" command ln -sf "$file" "$target" builtin source "$target" ^ /dev/null @@ -791,7 +795,7 @@ function __fisher_plugin_enable -a path for file in $path/completions/*.fish set -l base (basename "$file") - set -l target "$fish_config/completions/$base" + set -l target "$fish_path/completions/$base" command ln -sf "$file" "$target" builtin source "$target" ^ /dev/null @@ -832,13 +836,13 @@ function __fisher_plugin_disable -a path set base "$plugin_name.$base" end - set -l target "$fish_config/$dir/$base" + set -l target "$fish_path/$dir/$base" command rm -f "$target" functions -e "$name" - set -l backup_source "$fish_config/$dir/copy-$base" + set -l backup_source "$fish_path/$dir/copy-$base" if test -e "$backup_source" command mv "$backup_source" "$target" @@ -846,7 +850,7 @@ function __fisher_plugin_disable -a path end if test "$base" = "set_color_custom.fish" - set -l fish_colors_config "$fish_config/fish_colors" + set -l fish_colors_config "$fish_path/fish_colors" if test ! -f "$fish_colors_config" __fisher_reset_default_fish_colors @@ -861,24 +865,24 @@ function __fisher_plugin_disable -a path for file in $path/conf.d/*.{py,awk} set -l base (basename "$file") - command rm -f "$fish_config/conf.d/$base" + command rm -f "$fish_path/conf.d/$base" end for file in $path/{functions/,}*.{py,awk} set -l base (basename "$file") - command rm -f "$fish_config/functions/$base" + command rm -f "$fish_path/functions/$base" end for file in $path/conf.d/*.fish set -l base (basename "$file") - command rm -f "$fish_config/conf.d/$base" + command rm -f "$fish_path/conf.d/$base" end for file in $path/completions/*.fish set -l name (basename "$file" .fish) set -l base "$name.fish" - command rm -f "$fish_config/completions/$base" + command rm -f "$fish_path/completions/$base" complete -c "$name" --erase end @@ -1456,7 +1460,7 @@ end function __fisher_key_bindings_remove -a plugin_name - set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish" + set -l user_key_bindings "$fish_path/functions/fish_user_key_bindings.fish" if test ! -f "$user_key_bindings" return @@ -1493,7 +1497,7 @@ end function __fisher_key_bindings_append -a plugin_name file - set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish" + set -l user_key_bindings "$fish_path/functions/fish_user_key_bindings.fish" command mkdir -p (dirname "$user_key_bindings") command touch "$user_key_bindings" @@ -2155,6 +2159,7 @@ function __fisher_self_uninstall -a yn command rm -f "$fish_config"/{functions,completions}/$fisher_cmd_name.fish "$fisher_file" set -e fish_config + set -e fish_path set -e fisher_active_prompt set -e fisher_cache set -e fisher_config @@ -2416,4 +2421,3 @@ a snippet, i\.e, one or more \fI\.fish\fR files inside a directory named \fIconf .SS "How can I list plugins as dependencies to my plugin?" Create a new \fIfishfile\fR file at the root level of your project and write in the plugins\.' end -