Fish Interactive Shell のフルパス
質問
Fish Interactive シェルにフルパスを表示する方法はありますか。現在、ディレクトリに移動すると、次のシェルが表示されます。
millermj@Dodore ~/o/workspace
でも私はむしろ見たいです
millermj@Dodore ~/o-town/workspace
解決
新しいfishshell(V2.3)を使用すると、set -U fish_prompt_pwd_dir_length 0
を行うことができます。そして、それは完全なパスを使用します。私も自分のテーマの dartfish を使用します。以下の例を参照してください。
他のヒント
ここにあなたが探しているものを表示しなければならないprompt_pwd
の私のバージョンです
function prompt_pwd --description 'Print the current working directory, NOT shortened to fit the prompt'
if test "$PWD" != "$HOME"
printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|")
else
echo '~'
end
end
これはいつものように、ホームディレクトリのチルダを表示していますが、いくつかのディレクトリの深いるときのみ、各ディレクトリからの最初の文字を引っ張るsed
コマンドを削除します。
prompt_pwd
使用funced
を編集します。それはあなたが対話的に機能を変更することができます。コマンドライン型funced prompt_pwd
から。プロンプトがお好みに合わせて表示されたら、将来のセッションに固執する動作を行うためにfuncsave prompt_pwd
を使用します。
個人的には共有/デフォルトに触れるのは好きではありません。Fish は優れた機能設計を備えているので、それを活用してください。
作成する ~/.config/fish/functions/prompt_long_pwd.fish
内容:
function prompt_long_pwd --description 'Print the current working directory'
echo $PWD | sed -e "s|^$HOME|~|" -e 's|^/private||'
end
次に、単に編集するだけです ~/.config/fish/functions/fish_prompt.fish
使用する prompt_long_pwd
. 。私が使用するカスタムプロンプトは次のとおりです。
~/.config/fish/config.fish:
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_char_stagedstate "●"
set -g __fish_git_prompt_char_dirtystate "✚"
set -g __fish_git_prompt_char_untrackedfiles "…"
set -g __fish_git_prompt_char_conflictedstate "✖"
set -g __fish_git_prompt_char_cleanstate "✔"
set -g __fish_git_prompt_color_dirtystate blue
set -g __fish_git_prompt_color_stagedstate yellow
set -g __fish_git_prompt_color_invalidstate red
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
set -g __fish_git_prompt_color_cleanstate green bold
~/.config/fish/functions/fish_prompt.fish
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
# PWD
set_color $fish_color_cwd
echo -n (prompt_long_pwd)
set_color normal
printf '%s ' (__fish_git_prompt)
if not test $last_status -eq 0
set_color $fish_color_error
end
echo -n '$ '
end
prompt_pwd
機能を表示する機能を決定します。あなたが欲しいものを得るために、独自のバージョンを書くことができる必要があります。