进入 fish 把下面内容写入 setup_fish.fish 再执行 fish setup_fish.fish
对于一些 bash 才能使用的命令就直接在前面加上一个 bass
#!/usr/bin/env fish
# 1. 安装 Fisher 和所有插件
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher jorgebucaran/autopair.fish jethrokuan/z PatrickF1/fzf.fish nickeb96/puffer-fish edc/bass franciscolourenco/done meaningful-oo/sponge jorgebucaran/hydro
# 2. 确保配置目录存在
mkdir -p ~/.config/fish
# 3. 写入配置到 config.fish (覆盖写入)
cat > ~/.config/fish/config.fish << 'EOF'
set fish_greeting
set -g hydro_color_pwd blue
set -g hydro_color_git green
set -g hydro_color_error red
set -g hydro_color_prompt cyan
set -g hydro_multiline true
# ==========================================
# 核心命令替换 (使用 alias)
# ==========================================
alias l='ls --color=auto --group-directories-first'
alias s='ls --color=auto --group-directories-first'
alias ls='ls --color=auto --group-directories-first'
alias sl='ls --color=auto --group-directories-first'
alias la='ls -Ahl --color=auto --group-directories-first'
alias grep='grep --color=auto'
alias vi='nvim'
alias rm='rm -rI'
alias py='python3'
# ==========================================
# Git 快捷指令 (优化为 abbr)
# ==========================================
abbr ga 'git add .'
abbr gu 'git add --update'
abbr gaa 'git add -A'
abbr gs 'git status -sb'
abbr gd 'git diff'
abbr gcm 'git commit -m'
abbr gbh 'git branch'
abbr gch 'git checkout'
abbr gl 'git log --oneline -10 --abbrev-commit --all --graph --decorate --color'
abbr lg 'git log --oneline -10 --abbrev-commit --all --graph --decorate --color'
abbr glog 'git log --graph --decorate --all --color'
# ==========================================
# Docker 快捷指令 (优化为 abbr)
# ==========================================
abbr dp 'docker ps'
abbr di 'docker images'
abbr dpr 'docker pull'
abbr drun 'docker run -it --rm'
abbr dexec 'docker exec -it'
# ==========================================
# VSCode 检测
# ==========================================
if test "$TERM_PROGRAM" = "vscode"
# 极简提示符,禁用 git 状态
function fish_prompt
echo -n (prompt_pwd) ' > '
end
# 禁用右侧提示
function fish_right_prompt
# 空
end
# 禁用 Hydro 或复杂主题
set -g hydro_multiline false
end
EOF
# 4. 重新加载配置使其立即生效
source ~/.config/fish/config.fish