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
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# Build Web
set -e
if [ -z $GOOS ]; then
echo "GOOS is not set"
exit 1
fi
if [ -z $GOARCH ]; then
echo "GOARCH is not set"
exit 1
fi
OUTPUT_DIR=${1:-./output/$GOOS-$GOARCH}
cd web
pnpm install
pnpm build
cd ..
mkdir -p $OUTPUT_DIR/
rm -rf $OUTPUT_DIR/web/*
mkdir -p $OUTPUT_DIR/web/
cp -r web/out/* $OUTPUT_DIR/web/
+40 -18
View File
@@ -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 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 "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 "cd" -d "Change to fish config directory" 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 "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 "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 "help" -d "Show this help message" complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "help" -d "Show this help message"
# 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"
# Install 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 "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 "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 "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 "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 "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 "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 "font-install" -d "Install fonts"
# Init scripts # # 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 "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 "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 "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 "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 "cursor-init" -d "Initialize Cursor config"
complete -c ff -n "__fish_seen_subcommand_from make" -a "init-default-user" -d "Initialize default user (sudo)" # complete -c ff -n "__fish_seen_subcommand_from make" -a "init-default-user" -d "Initialize default user (sudo)"
# Clean scripts # Clean scripts
complete -c ff -n "__fish_seen_subcommand_from make" -a "brew-clean" -d "Clean Homebrew cache" 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 # Utils
complete -c ff -n "__fish_seen_subcommand_from make" -a "croncheck" -d "Check cron status" 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"
+65
View File
@@ -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
+4
View File
@@ -9,6 +9,8 @@ function ff
"poff|Disable proxy (proxy off)" \ "poff|Disable proxy (proxy off)" \
"pst|Show proxy status" \ "pst|Show proxy status" \
"make|Run dotfile Makefile commands" \ "make|Run dotfile Makefile commands" \
"script|Run script from script directory" \
"update|Update dotfile" \
"help|Show this help message" "help|Show this help message"
switch $argv[1] switch $argv[1]
@@ -48,6 +50,8 @@ 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
execute-script $argv[2..-1]
case help case help
echo "Usage: ff <command>" echo "Usage: ff <command>"
echo "" echo ""
+12
View File
@@ -94,6 +94,18 @@
# git reviewone foo.js bar.js # git reviewone foo.js bar.js
reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\" reviewone = !vim -p +\"tabdo Gdiff $REVIEW_BASE\" +\"let g:gitgutter_diff_base = '$REVIEW_BASE'\"
#git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Laily'; GIT_AUTHOR_EMAIL='i@laily.net'; GIT_COMMITTER_NAME='Laily'; GIT_COMMITTER_EMAIL='i@laily.net';" HEAD #git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Laily'; GIT_AUTHOR_EMAIL='i@laily.net'; GIT_COMMITTER_NAME='Laily'; GIT_COMMITTER_EMAIL='i@laily.net';" HEAD
# worktree
wt="worktree"
wta="worktree add"
wtb="worktree add -b"
wtr="worktree remove"
wtl="worktree list"
wtp="worktree prune"
# git wtbn feature-login # 新建分支 + worktree
wtbn="!f(){ git worktree add -b "$1" ../"$1"; }; f"
# git wtn bugfix-123 # 自动创建 ../bugfix-123 (使用同名分支)
wtn="!f(){ git worktree add ../"$1" "$1"; }; f"
[protocol "file"] [protocol "file"]
allow = always allow = always
+1 -1
View File
@@ -33,7 +33,7 @@ linters:
arguments: arguments:
- 15 - 15
severity: warning severity: warning
disabled: false disabled: true
- name: atomic - name: atomic
severity: warning severity: warning
disabled: false disabled: false
+3 -1
View File
@@ -264,5 +264,7 @@
"[java]": { "[java]": {
"editor.suggest.snippetsPreventQuickSuggestions": false "editor.suggest.snippetsPreventQuickSuggestions": false
}, },
"git.confirmSync": false "git.confirmSync": false,
"editor.dropIntoEditor.preferences": [],
"whichkey.bindingOverrides": []
} }