From dcabcb6d1567ef7f7f8dde08070f71069148e5f3 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Wed, 30 Apr 2025 17:45:05 -0400 Subject: [PATCH] AutoYADM commit: 2025-04-30 17:45:05 --- .config/fish/fish_plugins | 4 +-- .config/fish/fish_variables | 6 ++-- .config/fish/functions/fisher.fish | 56 ++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/.config/fish/fish_plugins b/.config/fish/fish_plugins index ee8f273c..daba188e 100644 --- a/.config/fish/fish_plugins +++ b/.config/fish/fish_plugins @@ -1,4 +1,3 @@ -jorgebucaran/fisher patrickf1/fzf.fish franciscolourenco/done jorgebucaran/replay.fish @@ -11,5 +10,6 @@ paldepind/projectdo wfxr/forgit jorgebucaran/nvm.fish danhper/fish-ssh-agent -ficcdaf/jrnl.fish ficcdaf/update.fish +~ficd/fisher +~ficd/jrnl.fish diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables index 431aa7b1..04be7190 100644 --- a/.config/fish/fish_variables +++ b/.config/fish/fish_variables @@ -4,12 +4,12 @@ SETUVAR EDITOR:hx SETUVAR --export XDG_CONFIG_HOME:/home/fic/\x2econfig SETUVAR Z_DATA_DIR:/home/fic/\x2elocal/share/z SETUVAR __fish_initialized:3800 +SETUVAR _fisher__7E_ficd_2F_fisher_files:/home/fic/\x2econfig/fish/functions/fisher\x2efish\x1e/home/fic/\x2econfig/fish/completions/fisher\x2efish +SETUVAR _fisher__7E_ficd_2F_jrnl_2E_fish_files:/home/fic/\x2econfig/fish/functions/jrnl\x2efish\x1e/home/fic/\x2econfig/fish/completions/jrnl\x2efish SETUVAR _fisher_danhper_2F_fish_2D_ssh_2D_agent_files:\x7e/\x2econfig/fish/functions/__ssh_agent_is_started\x2efish\x1e\x7e/\x2econfig/fish/functions/__ssh_agent_start\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fish\x2dssh\x2dagent\x2efish -SETUVAR _fisher_ficcdaf_2F_jrnl_2E_fish_files:\x7e/\x2econfig/fish/functions/jrnl\x2efish\x1e\x7e/\x2econfig/fish/completions/jrnl\x2efish SETUVAR _fisher_ficcdaf_2F_update_2E_fish_files:\x7e/\x2econfig/fish/functions/update\x2efish\x1e\x7e/\x2econfig/fish/completions/update\x2efish SETUVAR _fisher_franciscolourenco_2F_done_files:\x7e/\x2econfig/fish/conf\x2ed/done\x2efish SETUVAR _fisher_jorgebucaran_2F_autopair_2E_fish_files:\x7e/\x2econfig/fish/functions/_autopair_backspace\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_left\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_right\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_same\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_tab\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/autopair\x2efish -SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish SETUVAR _fisher_jorgebucaran_2F_replay_2E_fish_files:\x7e/\x2econfig/fish/functions/replay\x2efish\x1e\x7e/\x2econfig/fish/completions/replay\x2efish SETUVAR _fisher_jorgebucaran_2F_spark_2E_fish_files:\x7e/\x2econfig/fish/functions/spark\x2efish\x1e\x7e/\x2econfig/fish/completions/spark\x2efish @@ -18,7 +18,7 @@ SETUVAR _fisher_meaningful_2D_ooo_2F_sponge_files:\x7e/\x2econfig/fish/functions SETUVAR _fisher_nickeb96_2F_puffer_2D_fish_files:\x7e/\x2econfig/fish/functions/_puffer_fish_expand_bang\x2efish\x1e\x7e/\x2econfig/fish/functions/_puffer_fish_expand_dots\x2efish\x1e\x7e/\x2econfig/fish/functions/_puffer_fish_expand_lastarg\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/puffer_fish_key_bindings\x2efish SETUVAR _fisher_paldepind_2F_projectdo_files:\x7e/\x2econfig/fish/functions/projectdo_build\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_run\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_test\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_tool\x2efish\x1e\x7e/\x2econfig/fish/completions/projectdo\x2efish SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish -SETUVAR _fisher_plugins:jorgebucaran/fisher\x1epatrickf1/fzf\x2efish\x1efranciscolourenco/done\x1ejorgebucaran/replay\x2efish\x1ejorgebucaran/spark\x2efish\x1ejoseluisq/gitnow\x402\x2e12\x2e0\x1emeaningful\x2dooo/sponge\x1ejorgebucaran/autopair\x2efish\x1enickeb96/puffer\x2dfish\x1epaldepind/projectdo\x1ewfxr/forgit\x1ejorgebucaran/nvm\x2efish\x1edanhper/fish\x2dssh\x2dagent\x1eficcdaf/jrnl\x2efish\x1eficcdaf/update\x2efish +SETUVAR _fisher_plugins:patrickf1/fzf\x2efish\x1efranciscolourenco/done\x1ejorgebucaran/replay\x2efish\x1ejorgebucaran/spark\x2efish\x1ejoseluisq/gitnow\x402\x2e12\x2e0\x1emeaningful\x2dooo/sponge\x1ejorgebucaran/autopair\x2efish\x1enickeb96/puffer\x2dfish\x1epaldepind/projectdo\x1ewfxr/forgit\x1ejorgebucaran/nvm\x2efish\x1edanhper/fish\x2dssh\x2dagent\x1eficcdaf/update\x2efish\x1e\x7eficd/fisher\x1e\x7eficd/jrnl\x2efish SETUVAR _fisher_upgraded_to_4_4:\x1d SETUVAR _fisher_wfxr_2F_forgit_files:\x7e/\x2econfig/fish/conf\x2ed/bin\x1e\x7e/\x2econfig/fish/conf\x2ed/forgit\x2eplugin\x2efish\x1e\x7e/\x2econfig/fish/completions/_git\x2dforgit\x1e\x7e/\x2econfig/fish/completions/git\x2dforgit\x2ebash\x1e\x7e/\x2econfig/fish/completions/git\x2dforgit\x2efish SETUVAR abbr_path:/home/fic/\x2econfig/fish/conf\x2ed/abbr\x2efish diff --git a/.config/fish/functions/fisher.fish b/.config/fish/functions/fisher.fish index e915cb88..4023c00f 100644 --- a/.config/fish/functions/fisher.fish +++ b/.config/fish/functions/fisher.fish @@ -22,6 +22,45 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" case install update remove isatty || read --local --null --array stdin && set --append argv $stdin + function _expand_home + # helper function to safely expand ~ into $HOME, and vice versa. + # needed because plugin URLs containing literal ~ are mangled otherwise. + # it is a drop-in for both: + # echo $path | string replace -- \~ ~ + # string replace -- \~ ~ $path + # The difference: will _only_ expand ~ into $HOME if: + # it's at the start of the line, and followed by either EOL or / + # the -r/--reverse flag reverses the logic, and turns the absolute + # home path (expansion of ~) into a literal \~ + argparse r/reverse -- $argv + set --local input + # read stdin if no args + if test (count $argv) -eq 0 + while read --line line + set --append input $line + end + else + set input $argv + end + + for path in $input + # get the current absolute home path + set -l home ~ + # check for the reverse flag + # only expand if $home is at start of line, followed by / or EOL + if set -ql _flag_reverse && string match -rq "^$home"'($|/)' + string replace -- ~ \~ path + else if string match -rq '^~($|/)' -- $path + # only expand if ~ at start of line + # and followed by / or EOL + string replace -- \~ ~ path + else + # don't modify string if doesn't pass checks + echo $path + end + end + end + set --local install_plugins set --local update_plugins set --local remove_plugins @@ -29,7 +68,7 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" set --local old_plugins $_fisher_plugins set --local new_plugins - test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | string replace -- \~ ~) + test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | _expand_home) if ! set --query argv[2] if test "$cmd" != update @@ -92,6 +131,9 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1]) set name (string split -- / \$path)[-1] set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz + else if set path (string replace --regex -- '^(https://git\.sr\.ht/|(git\.)?sr\.ht/)' '' \$repo[1] || string match -q '~*' \$repo[1]) + set name (string split -- / \$path)[-1] + set url https://git.sr.ht/\$path/archive/\$repo[2].tar.gz else set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2] end @@ -134,11 +176,11 @@ 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 | string replace -- \~ ~ + printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | _expand_home set --erase _fisher_plugins[$index] end - command rm -rf (string replace -- \~ ~ $$plugin_files_var) + command rm -rf (_expand_home $$plugin_files_var) functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var) @@ -178,14 +220,14 @@ function fisher --argument-names cmd --description "A plugin manager for Fish" 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 | string replace -- ~ \~) + set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | _expand_home --reverse) 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 | string replace -- \~ ~ + printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | _expand_home - for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~) + for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | _expand_home) source $file if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file) emit {$name}_$event @@ -233,7 +275,7 @@ if ! set --query _fisher_upgraded_to_4_4 fisher update >/dev/null 2>/dev/null else for var in (set --names | string match --entire --regex '^_fisher_.+_files$') - set $var (string replace -- ~ \~ $$var) + set $var (_expand_home --reverse $$var) end functions --erase _fisher_fish_postexec end