fix: add alias for script

This commit is contained in:
2026-06-27 12:00:04 +08:00
parent a43e8bc885
commit 8dcd6e3ac9
4 changed files with 9 additions and 12 deletions
+4 -3
View File
@@ -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 "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 "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 "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 "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)" 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
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 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; 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 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 not __fish_seen_subcommand_from help -h --help (__ff_list_scripts)" -a '(__ff_complete_scripts)' -d "Script name"
+1 -1
View File
@@ -8,7 +8,7 @@ function execute-script
set -l script_dir $dotfile_dir/script set -l script_dir $dotfile_dir/script
set -l script_name $argv[1] 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 contains -- $script_name -h --help help
if test -z "$script_name"; or test (count $argv) -eq 1 if test -z "$script_name"; or test (count $argv) -eq 1
script-show-catalog script-show-catalog
+2 -6
View File
@@ -11,6 +11,7 @@ function ff
"pst|Show proxy status" \ "pst|Show proxy status" \
"make|Run dotfile Makefile commands" \ "make|Run dotfile Makefile commands" \
"script|Run script from script directory" \ "script|Run script from script directory" \
"s|Alias for script" \
"update|Update dotfile" \ "update|Update dotfile" \
"region|Toggle or set CN_REGION (mirror/proxy region)" \ "region|Toggle or set CN_REGION (mirror/proxy region)" \
"ssh|SSH init (keys + config.d) or copy config to remote" \ "ssh|SSH init (keys + config.d) or copy config to remote" \
@@ -62,12 +63,7 @@ function ff
else else
echo "Error: Dotfile directory not found at $dotfile_dir" echo "Error: Dotfile directory not found at $dotfile_dir"
end end
case script case script s
if not functions -q execute-script
source ~/.dotfile/fish/functions/execute-script.fish
end
execute-script $argv[2..-1]
case s
if not functions -q execute-script if not functions -q execute-script
source ~/.dotfile/fish/functions/execute-script.fish source ~/.dotfile/fish/functions/execute-script.fish
end end
+2 -2
View File
@@ -110,7 +110,7 @@ end
function script-show-catalog function script-show-catalog
set -l script_dir ~/.dotfile/script set -l script_dir ~/.dotfile/script
echo "Usage: ff script <name> [args...]" echo "Usage: ff script <name> [args...] (alias: ff s)"
echo "" echo ""
echo "Scripts in $script_dir:" echo "Scripts in $script_dir:"
echo "" echo ""
@@ -122,5 +122,5 @@ function script-show-catalog
end end
echo "" echo ""
echo "提示: ff script <name> -h 查看单个脚本内的详细帮助" echo "提示: ff s <name> -h 查看单个脚本内的详细帮助"
end end