feat: add command

This commit is contained in:
2025-10-19 18:02:14 +08:00
parent 2bd26fc9ef
commit 03b384b819
9 changed files with 231 additions and 54 deletions
+40
View File
@@ -0,0 +1,40 @@
# Completions for ff command
complete -c ff -f
set -l ff_subcommands reload edit cd pon poff pst make 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"
complete -c ff -n "not __fish_seen_subcommand_from $ff_subcommands" -a "pon" -d "Enable proxy (proxy on)"
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 "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"
# 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"
# 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"
complete -c ff -n "__fish_seen_subcommand_from make" -a "docker-clean" -d "Clean Docker resources"
# Utils
complete -c ff -n "__fish_seen_subcommand_from make" -a "croncheck" -d "Check cron status"
+1 -42
View File
@@ -80,7 +80,7 @@ end
# git
# alias
alias gitb="git branch --show-current | tr -d '\n' | pbcopy"
alias gci="golangci-lint run -c=~/.dotfile/.golangci.yml ./..."
alias gci="golangci-lint run -c=~/.dotfile/golang/golangci.yml ./..."
alias gmt="go mod tidy"
alias gtc="go test -gcflags=all=-l -cover ./..."
alias swg="swag init -o docs -g "
@@ -143,47 +143,6 @@ if status is-interactive
# Commands to run in interactive sessions can go here
end
# reload conf
function fre
source ~/.config/fish/config.fish
echo "Fish configuration updated!"
end
function refish
source ~/.config/fish/config.fish
echo "Fish configuration updated!"
end
# vi config
alias fvi="vim ~/.config/fish/custom.fish"
# cd config
alias fcd="cd ~/.config/fish/"
function punset
set -e http_proxy
set -e https_proxy
set -e ftp_proxy
set -e all_proxy
set -e HTTP_PROXY
set -e HTTPS_PROXY
set -e FTP_PROXY
set -e ALL_PROXY
echo "Proxy environment variables have been reset."
pshow
end
function pshow
export | grep -i proxy
end
function pset
set -gx https_proxy http://127.0.0.1:7890
set -gx http_proxy http://127.0.0.1:7890
set -gx all_proxy socks5://127.0.0.1:7891
echo "Proxy environment variables have been set."
pshow
end
# source env
function source_env
for line in (cat $argv | grep -v '^#' | grep -v '^\s*$')
+67
View File
@@ -0,0 +1,67 @@
# Fast commands management
function ff
# 定义命令和描述(格式:命令|描述)
set -l commands \
"reload|Reload fish configuration" \
"edit|Edit custom fish configuration" \
"cd|Change to fish config directory" \
"pon|Enable proxy (proxy on)" \
"poff|Disable proxy (proxy off)" \
"pst|Show proxy status" \
"make|Run dotfile Makefile commands" \
"help|Show this help message"
switch $argv[1]
case reload
source ~/.config/fish/config.fish
echo "Fish configuration reloaded!"
case edit
vim ~/.config/fish/custom.fish
case cd
cd ~/.config/fish/
case pon
set -gx https_proxy http://127.0.0.1:7890
set -gx http_proxy http://127.0.0.1:7890
set -gx all_proxy socks5://127.0.0.1:7890
echo "✓ Proxy enabled"
export | grep -i proxy
case poff
set -e http_proxy
set -e https_proxy
set -e ftp_proxy
set -e all_proxy
set -e HTTP_PROXY
set -e HTTPS_PROXY
set -e FTP_PROXY
set -e ALL_PROXY
echo "✓ Proxy disabled"
export | grep -i proxy
case pst
export | grep -i proxy
case make
# 切换到 dotfile 目录执行脚本管理 makefile
set -l dotfile_dir ~/.dotfile
if test -d $dotfile_dir
make -f $dotfile_dir/Makefile.scripts -C $dotfile_dir $argv[2..-1]
else
echo "Error: Dotfile directory not found at $dotfile_dir"
end
case help
echo "Usage: ff <command>"
echo ""
echo "Commands:"
# 自动生成帮助信息
for cmd in $commands
set -l parts (string split '|' $cmd)
printf " %-10s %s\n" $parts[1] $parts[2]
end
case '*'
if test -z "$argv[1]"
echo "Error: No command specified"
else
echo "Error: Unknown command '$argv[1]'"
end
echo "Run 'ff help' for usage information"
end
end