From 8dcd6e3ac915c83f5bbfacf0995e56fde1871ba3 Mon Sep 17 00:00:00 2001 From: laily Date: Sat, 27 Jun 2026 12:00:04 +0800 Subject: [PATCH] fix: add alias for script --- fish/completions/ff.fish | 7 ++++--- fish/functions/execute-script.fish | 2 +- fish/functions/ff.fish | 8 ++------ fish/functions/script-catalog.fish | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/fish/completions/ff.fish b/fish/completions/ff.fish index d503fb4..d41cdfe 100644 --- a/fish/completions/ff.fish +++ b/fish/completions/ff.fish @@ -10,6 +10,7 @@ complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "poff" -d complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pst" -d "Show proxy status" # complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "make" -d "Run dotfile Makefile commands" complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "script" -d "Run script from script directory" +complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "s" -d "Run script (alias for script)" complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "help" -d "Show this help message" complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "region" -d "Toggle or set CN_REGION (mirror/proxy region)" @@ -82,7 +83,7 @@ function __ff_complete_scripts end end -complete -c ff -n "__fish_seen_subcommand_from script; and test (count (commandline -opc)) -eq 2" -s h -l help -d "List all scripts and descriptions" -complete -c ff -n "__fish_seen_subcommand_from script; and test (count (commandline -opc)) -eq 2" -a help -d "List all scripts and descriptions" -complete -c ff -n "__fish_seen_subcommand_from script; and not __fish_seen_subcommand_from help -h --help (__ff_list_scripts)" -a '(__ff_complete_scripts)' -d "Script name" +complete -c ff -n "__fish_seen_subcommand_from script s; and test (count (commandline -opc)) -eq 2" -s h -l help -d "List all scripts and descriptions" +complete -c ff -n "__fish_seen_subcommand_from script s; and test (count (commandline -opc)) -eq 2" -a help -d "List all scripts and descriptions" +complete -c ff -n "__fish_seen_subcommand_from script s; and not __fish_seen_subcommand_from help -h --help (__ff_list_scripts)" -a '(__ff_complete_scripts)' -d "Script name" diff --git a/fish/functions/execute-script.fish b/fish/functions/execute-script.fish index 0b3f551..a447ec7 100644 --- a/fish/functions/execute-script.fish +++ b/fish/functions/execute-script.fish @@ -8,7 +8,7 @@ function execute-script set -l script_dir $dotfile_dir/script set -l script_name $argv[1] - # ff script -h / --help / help + # ff script|s -h / --help / help if test -z "$script_name"; or contains -- $script_name -h --help help if test -z "$script_name"; or test (count $argv) -eq 1 script-show-catalog diff --git a/fish/functions/ff.fish b/fish/functions/ff.fish index 263e2fc..78f1f2a 100644 --- a/fish/functions/ff.fish +++ b/fish/functions/ff.fish @@ -11,6 +11,7 @@ function ff "pst|Show proxy status" \ "make|Run dotfile Makefile commands" \ "script|Run script from script directory" \ + "s|Alias for script" \ "update|Update dotfile" \ "region|Toggle or set CN_REGION (mirror/proxy region)" \ "ssh|SSH init (keys + config.d) or copy config to remote" \ @@ -62,12 +63,7 @@ function ff else echo "Error: Dotfile directory not found at $dotfile_dir" end - case script - if not functions -q execute-script - source ~/.dotfile/fish/functions/execute-script.fish - end - execute-script $argv[2..-1] - case s + case script s if not functions -q execute-script source ~/.dotfile/fish/functions/execute-script.fish end diff --git a/fish/functions/script-catalog.fish b/fish/functions/script-catalog.fish index 47c07ba..d4d03e4 100644 --- a/fish/functions/script-catalog.fish +++ b/fish/functions/script-catalog.fish @@ -110,7 +110,7 @@ end function script-show-catalog set -l script_dir ~/.dotfile/script - echo "Usage: ff script [args...]" + echo "Usage: ff script [args...] (alias: ff s)" echo "" echo "Scripts in $script_dir:" echo "" @@ -122,5 +122,5 @@ function script-show-catalog end echo "" - echo "提示: ff script -h 查看单个脚本内的详细帮助" + echo "提示: ff s -h 查看单个脚本内的详细帮助" end