fish をイジイジしています。
プロンプトのカレント・ディレクトリの略記がイイですね。ああいうのは短い方が好みです。
でも zsh 好きとしては右側に表示させたいな、と……思ったら、サポートされていました。
で、俺の~/.config/fish/functions
を見てやー。
fish_right_prompt.fish
function fish_right_prompt --description '右側にカレント・ディレクトリを表示'
prompt_pwd
end
fish_prompt.fish
# ほとんどデフォルトです
function fish_prompt --description 'Write out the prompt'
# Just calculate this once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
set -l color_cwd
set -l suffix
switch $USER
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '>'
end
# (prompt_pwd) を消してます
echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (set_color normal) "$suffix "
end
git のブランチ表示はどうしようかなあ……。fish_config
のサンプルはどれも今ひとつで……。
追記
これでイイや……。
fish_right_prompt.fish
function fish_right_prompt --description '右側に pwd と git status を表示'
prompt_pwd
__terlar_git_prompt
end
__terlar_git_prompt
は /usr/local/Cellar/fish/2.3.1/share/fish/functions/__terlar_git_prompt.fish
で定義してあります。
追記の追記
version 2.7.2 に上げたら、なんか git status の表示がおかしくなったので、 __fish_git_prompt
に変更……。
fish_right_prompt.fish
function fish_right_prompt --description '右側に pwd と git status を表示'
prompt_pwd
__fish_git_prompt
end
config.fish
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_showuntrackedfiles 'yes'
set __fish_git_prompt_show_informative_status 'yes'
set __fish_git_prompt_showcolorhints 'yes'
以下を参考にしました。