現在用了下 fish 2,感覺改善好多。
以前很多程序都帶bash和 zsh的tab補全,fish沒有,得自己寫,麻煩。現在`fish_update_completions` 可以自動根據 man 生成 tab補全。
新增的 auto suggestion 功能也很贊。
分享一下我的fish提示符,(是的,fish 2已經支持像 zsh 一樣的左右提示符了。)
左邊的保持簡潔,學習rc用
代码: 全选
;
上一個命令exit不爲0的時候用紅色提醒。
代码: 全选
function fish_prompt
set --local last_status $status
set --local red (set_color -o red)
if test $last_status -ne 0
set error_exit "$red($last_status) "
end
echo -n "$error_exit; "
z --add "$PWD"
end
還有git的branch名稱,以及是否有髒文件
代码: 全选
function fish_right_prompt
if not set -q -g __fish_robbyrussell_functions_defined
set -g __fish_robbyrussell_functions_defined
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (git status -s --ignore-submodules=dirty ^/dev/null)
end
end
set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow)
set -l red (set_color -o red)
set -l blue (set_color -o blue)
set -l normal (set_color normal)
set -l arrow "$cyan➜ "
set -l cwd $normal(prompt_pwd)
if [ (_git_branch_name) ]
set -l git_branch $blue(_git_branch_name)
set git_info "$blue ($git_branch$blue)"
if [ (_is_git_dirty) ]
set -l dirty "$yellow ✗"
set git_info "$git_info$dirty"
end
end
echo -n -s $arrow ' '$cwd $git_info $normal ' '
end