feat: update toggle region
This commit is contained in:
@@ -8,3 +8,4 @@ log
|
|||||||
cn.sh
|
cn.sh
|
||||||
__pycache__
|
__pycache__
|
||||||
Makefile
|
Makefile
|
||||||
|
.claude/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Completions for ff command
|
# Completions for ff command
|
||||||
complete -c ff -f
|
complete -c ff -f
|
||||||
set -l ff_subcommands reload edit pon poff pst make script help
|
set -l ff_subcommands reload edit fish dotfile pon poff pst make script s update help region
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "reload" -d "Reload fish configuration"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "reload" -d "Reload fish configuration"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "edit" -d "Edit custom fish configuration"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "edit" -d "Edit custom fish configuration"
|
||||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "fish" -d "Change to fish config directory"
|
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "fish" -d "Change to fish config directory"
|
||||||
@@ -12,6 +12,8 @@ complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pst" -d
|
|||||||
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 "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 "__fish_seen_subcommand_from region" -a toggle -d "Toggle CN_REGION (国内/国外)"
|
||||||
|
|
||||||
# # make 子命令的补全 - 直接使用脚本文件名
|
# # make 子命令的补全 - 直接使用脚本文件名
|
||||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "help" -d "Show all make targets"
|
# complete -c ff -n "__fish_seen_subcommand_from make" -a "help" -d "Show all make targets"
|
||||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "list" -d "List all available scripts"
|
# complete -c ff -n "__fish_seen_subcommand_from make" -a "list" -d "List all available scripts"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ function ff
|
|||||||
"make|Run dotfile Makefile commands" \
|
"make|Run dotfile Makefile commands" \
|
||||||
"script|Run script from script directory" \
|
"script|Run script from script directory" \
|
||||||
"update|Update dotfile" \
|
"update|Update dotfile" \
|
||||||
|
"region|Toggle or set CN_REGION (mirror/proxy region)" \
|
||||||
"help|Show this help message"
|
"help|Show this help message"
|
||||||
|
|
||||||
# 确保 execute-script 可用(在 fish 自动加载前手动引入一次)
|
# 确保 execute-script 可用(在 fish 自动加载前手动引入一次)
|
||||||
@@ -82,6 +83,24 @@ function ff
|
|||||||
cd ~/.dotfile
|
cd ~/.dotfile
|
||||||
git pull origin main
|
git pull origin main
|
||||||
cd -
|
cd -
|
||||||
|
case region
|
||||||
|
set -l sub toggle
|
||||||
|
if test (count $argv) -ge 2
|
||||||
|
set sub $argv[2]
|
||||||
|
end
|
||||||
|
switch $sub
|
||||||
|
case toggle
|
||||||
|
if test "$CN_REGION" = "1"
|
||||||
|
set -gx CN_REGION 0
|
||||||
|
echo "Switched to: 0 (国外)"
|
||||||
|
else
|
||||||
|
set -gx CN_REGION 1
|
||||||
|
echo "Switched to: 1 (国内)"
|
||||||
|
end
|
||||||
|
case '*'
|
||||||
|
echo "Usage: ff region [toggle]"
|
||||||
|
echo "Unknown subcommand: $sub"
|
||||||
|
end
|
||||||
case '*'
|
case '*'
|
||||||
if test -z "$argv[1]"
|
if test -z "$argv[1]"
|
||||||
echo "Error: No command specified"
|
echo "Error: No command specified"
|
||||||
|
|||||||
Reference in New Issue
Block a user