【发布时间】:2010-10-26 09:40:52
【问题描述】:
Fish Interactive shell 中是否有办法显示完整路径。目前,当我导航到一个目录时,我得到了以下 shell。
millermj@Dodore ~/o/workspace
但我更愿意看到
millermj@Dodore ~/o-town/workspace
【问题讨论】:
Fish Interactive shell 中是否有办法显示完整路径。目前,当我导航到一个目录时,我得到了以下 shell。
millermj@Dodore ~/o/workspace
但我更愿意看到
millermj@Dodore ~/o-town/workspace
【问题讨论】:
只是想如果您偶然发现此问题并且您的鱼没有响应 fish_prompt_pwd_dir_length 变量,我会提醒大家尝试升级 omf,然后更新您正在使用的 omf 主题。然后做一些选择不同主题的组合,重新打开外壳,然后再次选择不同的主题。这对我有用。祝你好运!
【讨论】:
使用:创建~/.config/fish/functions/prompt_long_pwd.fish:
function prompt_long_pwd --description 'Print the full working directory'
echo $PWD
end
在~/.config/fish/functions/fish_prompt.fish 中将(prompt_pwd) (set_color normal) 更改为(prompt_long_pwd) (set_color normal)。
(prompt_pwd) 将目录名称替换为目录的第一个字母,我有时也觉得这很烦人。你也可以大概修改一下原来的命令prompt_pwd,我没试过。
这个答案是从之前的answer 修改而来的,它显示了完整的目录,同时保留了默认提示的其他部分。关键变化在于~/.config/fish/functions/prompt_long_pwd.fish 中的表达式。
【讨论】:
使用新的fishshell (v2.3),您可以使用set -U fish_prompt_pwd_dir_length 0。它将使用完整路径。我也使用dartfish 作为我的主题。请参见下面的示例:
【讨论】:
2.3.1。
我个人不喜欢触摸共享/默认值。 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 版本,应该会显示您要查找的内容:
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 使该行为在以后的会话中持续存在。
【讨论】:
if,在主目录中,sed 仍然会产生~
/V/Y/U/s/D/p001 而不是Volumes/Yosemite I am/Users/slippyd/Desktop/p001(echo $PWD) 的结果。
fish_config,它会在你的浏览器中打开一个fish-config web界面。现在您可以从一长串提示选项中进行选择..
prompt_pwd 函数确定要显示的函数。你应该能够编写自己的版本来获得你想要的。
【讨论】: