feat: update git alias
This commit is contained in:
+40
-18
@@ -1,6 +1,6 @@
|
||||
# Completions for ff command
|
||||
complete -c ff -f
|
||||
set -l ff_subcommands reload edit cd pon poff pst make help
|
||||
set -l ff_subcommands reload edit cd pon poff pst make script help
|
||||
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 "cd" -d "Change to fish config directory"
|
||||
@@ -8,28 +8,29 @@ complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pon" -d
|
||||
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "poff" -d "Disable proxy (proxy off)"
|
||||
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 "help" -d "Show this help message"
|
||||
|
||||
# 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 "list" -d "List all available scripts"
|
||||
# # 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 "list" -d "List all available scripts"
|
||||
|
||||
# Install scripts
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "brew-install" -d "Install Homebrew"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "docker-install" -d "Install Docker"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-install" -d "Install Neovim"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "python-install" -d "Install Python"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "gvm-install" -d "Install Go Version Manager"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "firacode-install" -d "Install FiraCode font"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "font-install" -d "Install fonts"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "brew-install" -d "Install Homebrew"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "docker-install" -d "Install Docker"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-install" -d "Install Neovim"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "python-install" -d "Install Python"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "gvm-install" -d "Install Go Version Manager"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "firacode-install" -d "Install FiraCode font"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "font-install" -d "Install fonts"
|
||||
|
||||
# Init scripts
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "fish-init" -d "Initialize Fish shell"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "git-init" -d "Initialize Git config"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-init" -d "Initialize Neovim config"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "tmux-init" -d "Initialize Tmux config"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "cursor-init" -d "Initialize Cursor config"
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "init-default-user" -d "Initialize default user (sudo)"
|
||||
# # Init scripts
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "fish-init" -d "Initialize Fish shell"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "git-init" -d "Initialize Git config"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "nvim-init" -d "Initialize Neovim config"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "tmux-init" -d "Initialize Tmux config"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "cursor-init" -d "Initialize Cursor config"
|
||||
# complete -c ff -n "__fish_seen_subcommand_from make" -a "init-default-user" -d "Initialize default user (sudo)"
|
||||
|
||||
# Clean scripts
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "brew-clean" -d "Clean Homebrew cache"
|
||||
@@ -38,3 +39,24 @@ complete -c ff -n "__fish_seen_subcommand_from make" -a "docker-clean" -d "Clean
|
||||
# Utils
|
||||
complete -c ff -n "__fish_seen_subcommand_from make" -a "croncheck" -d "Check cron status"
|
||||
|
||||
# script 子命令的补全 - 动态列出 script 目录下的脚本
|
||||
function __ff_list_scripts
|
||||
set -l script_dir ~/.dotfile/script
|
||||
if test -d $script_dir
|
||||
# 列出 .sh 文件
|
||||
for script in $script_dir/*.sh
|
||||
if test -f $script
|
||||
basename $script | string replace -r '\.sh$' ''
|
||||
end
|
||||
end
|
||||
# 列出 .py 文件
|
||||
for script in $script_dir/*.py
|
||||
if test -f $script
|
||||
basename $script | string replace -r '\.py$' ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
complete -c ff -n "__fish_seen_subcommand_from script" -a '(__ff_list_scripts)' -d "Script name"
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# ----- Git worktree native completions -----
|
||||
|
||||
# 列出分支
|
||||
function __git_branches
|
||||
git branch --format="%(refname:short)" 2>/dev/null
|
||||
end
|
||||
|
||||
# 列出 worktree 路径
|
||||
function __git_worktree_paths
|
||||
git worktree list --porcelain 2>/dev/null \
|
||||
| awk '/worktree/ {print $2}'
|
||||
end
|
||||
|
||||
# -----------------------
|
||||
# Worktree 别名补全
|
||||
# -----------------------
|
||||
|
||||
# git wtl → worktree list
|
||||
complete -f -c git -n '__fish_seen_subcommand_from wtl' -a ''
|
||||
|
||||
# git wtp → worktree prune
|
||||
complete -f -c git -n '__fish_seen_subcommand_from wtp' -a ''
|
||||
|
||||
# git wta → worktree add <path> <branch>
|
||||
complete -c git -n '__fish_seen_subcommand_from wta' \
|
||||
-a '(__git_branches)' \
|
||||
-d "Branch to add worktree for"
|
||||
|
||||
# git wtb → worktree add -b <newbranch> <path> <base>
|
||||
complete -c git -n '__fish_seen_subcommand_from wtb' \
|
||||
-a '(__git_branches)' \
|
||||
-d "Base branch to create new branch from"
|
||||
|
||||
# git wtr → worktree remove <path>
|
||||
complete -c git -n '__fish_seen_subcommand_from wtr' \
|
||||
-a '(__git_worktree_paths)' \
|
||||
-d "Existing worktree paths"
|
||||
|
||||
# ------------------------------
|
||||
# 原生 git worktree 补全增强
|
||||
# ------------------------------
|
||||
|
||||
# git worktree add <path> <branch>
|
||||
complete -c git -n '__fish_seen_subcommand_from worktree; and __fish_seen_subcommand_from add' \
|
||||
-a '(__git_branches)' \
|
||||
-d "Branch to checkout"
|
||||
|
||||
# git worktree remove <path>
|
||||
complete -c git -n '__fish_seen_subcommand_from worktree; and __fish_seen_subcommand_from remove' \
|
||||
-a '(__git_worktree_paths)' \
|
||||
-d "Worktree path"
|
||||
@@ -0,0 +1,65 @@
|
||||
# Execute script from script directory
|
||||
function execute-script
|
||||
# 执行 script 目录下的脚本
|
||||
set -l dotfile_dir ~/.dotfile
|
||||
set -l script_dir $dotfile_dir/script
|
||||
set -l script_name $argv[1]
|
||||
|
||||
if test -z "$script_name"
|
||||
echo "Error: No script name specified"
|
||||
echo "Usage: execute-script <script_name> [args...]"
|
||||
echo ""
|
||||
echo "Available scripts:"
|
||||
if test -d $script_dir
|
||||
for script in $script_dir/*.sh $script_dir/*.py
|
||||
if test -f $script
|
||||
set -l basename (basename $script)
|
||||
echo " $basename"
|
||||
end
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
# 尝试不同的扩展名
|
||||
set -l script_path ""
|
||||
for ext in sh py
|
||||
set -l test_path $script_dir/$script_name.$ext
|
||||
if test -f $test_path
|
||||
set script_path $test_path
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
# 如果没找到,尝试直接使用提供的名称
|
||||
if test -z "$script_path"
|
||||
set script_path $script_dir/$script_name
|
||||
end
|
||||
|
||||
if test -f $script_path
|
||||
echo "Running: $script_path"
|
||||
if test -x $script_path
|
||||
$script_path $argv[2..-1]
|
||||
else
|
||||
# 根据文件类型选择解释器
|
||||
if string match -q "*.py" $script_path
|
||||
python3 $script_path $argv[2..-1]
|
||||
else
|
||||
bash $script_path $argv[2..-1]
|
||||
end
|
||||
end
|
||||
else
|
||||
echo "Error: Script not found: $script_name"
|
||||
echo "Available scripts:"
|
||||
if test -d $script_dir
|
||||
for script in $script_dir/*.sh $script_dir/*.py
|
||||
if test -f $script
|
||||
set -l basename (basename $script)
|
||||
echo " $basename"
|
||||
end
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,8 @@ function ff
|
||||
"poff|Disable proxy (proxy off)" \
|
||||
"pst|Show proxy status" \
|
||||
"make|Run dotfile Makefile commands" \
|
||||
"script|Run script from script directory" \
|
||||
"update|Update dotfile" \
|
||||
"help|Show this help message"
|
||||
|
||||
switch $argv[1]
|
||||
@@ -48,6 +50,8 @@ function ff
|
||||
else
|
||||
echo "Error: Dotfile directory not found at $dotfile_dir"
|
||||
end
|
||||
case script
|
||||
execute-script $argv[2..-1]
|
||||
case help
|
||||
echo "Usage: ff <command>"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user