From 1662b799eb929bab00f0c7995dcf582f98e35ce3 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Sat, 2 Jul 2022 15:56:06 -0300 Subject: [PATCH] Replace $HOME with ~ in plugin state (#611) Now it should be easier to sync dotfiles across machines that have different $HOME locations. Close #611 --- functions/fisher.fish | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/functions/fisher.fish b/functions/fisher.fish index 2579bb1..fde5ad3 100644 --- a/functions/fisher.fish +++ b/functions/fisher.fish @@ -134,11 +134,12 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var) emit {$name}_uninstall end - printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var + printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~ set --erase _fisher_plugins[$index] end - command rm -rf $$plugin_files_var + command rm -rf (string replace -- \~ ~ $$plugin_files_var) + functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var) for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var) @@ -176,14 +177,15 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" end set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files - set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files) + + set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~) contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin contains -- $plugin $install_plugins && set --local event install || set --local event update - printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var + printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~ - for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var) + for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~) source $file if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file) emit {$name}_$event @@ -221,14 +223,17 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" end end -## Migrations ## -function _fisher_fish_postexec --on-event fish_postexec +if ! set --query _fisher_upgraded_to_4_4 + set --universal _fisher_upgraded_to_4_4 if functions --query _fisher_list + set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share + command rm -rf $XDG_DATA_HOME/fisher + functions --erase _fisher_{list,plugin_parse} fisher update >/dev/null 2>/dev/null - set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share - test -e $XDG_DATA_HOME/fisher && command rm -rf $XDG_DATA_HOME/fisher - functions --erase _fisher_list _fisher_plugin_parse - set --erase fisher_data + else + for var in (set --names | string match --entire --regex '^_fisher_.+_files$') + set $var (string replace -- ~ \~ $$var) + end + functions --erase _fisher_fish_postexec end - functions --erase _fisher_fish_postexec end