在Fish Interactive shell中是否有一种方法可以显示完整的路径。目前,当我导航到一个目录时,我得到了以下shell。
millermj@Dodore ~/o/workspace但我宁愿看到
millermj@Dodore ~/o-town/workspace发布于 2016-05-20 11:47:58
发布于 2010-04-06 02:31:06
以下是我的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使该行为在以后的会话中保持不变。
发布于 2014-11-01 04:14:10
我个人不喜欢接触共享/默认设置。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 '$ '
endhttps://stackoverflow.com/questions/866989
复制相似问题