フルパスを表示する方法はFishInteractiveシェルにありますか?現在、ディレクトリに移動すると、次のシェルが表示されます。
millermj@Dodore ~/o/workspace
しかし、私はむしろ見たい
millermj@Dodore ~/o-town/workspace
新しいフィッシュシェル (v2.3) を使用すると、次のことができますset -U fish_prompt_pwd_dir_length 0。そして、フルパスを使用します。また、ダーツフィッシュをテーマに使用しています。以下の例を参照してください。
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関数を決定します。必要なものを取得するには、独自のバージョンを作成できる必要があります。