feat: update git alias

This commit is contained in:
2025-11-18 14:25:09 +08:00
parent d9bce3b9ee
commit 9bd43f9f9c
8 changed files with 202 additions and 20 deletions
+40 -18
View File
@@ -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"
+51
View File
@@ -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"