Mil*_*ous 28 unix macos path fish
Fish Interactive shell中是否有一种方法可以显示完整路径.目前,当我导航到目录时,我得到以下shell.
millermj@Dodore ~/o/workspace
Run Code Online (Sandbox Code Playgroud)
但我宁愿看到
millermj@Dodore ~/o-town/workspace
Run Code Online (Sandbox Code Playgroud)
mic*_*ael 16
这是我的版本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
Run Code Online (Sandbox Code Playgroud)
这将像往常一样显示主目录的波浪号,但是sed
当你有几个目录时,它会删除只从每个目录中拉出第一个字母的命令.
编辑prompt_pwd
使用funced
.它将允许您以交互方式更改功能.从命令行类型funced prompt_pwd
.根据您的喜好显示提示后,请使用funcsave prompt_pwd
此操作在将来的会话中保持不变.
我个人不喜欢触摸共享/默认值.鱼有很棒的功能设计,所以杠杆化.
~/.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
Run Code Online (Sandbox Code Playgroud)
然后只需编辑~/.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
Run Code Online (Sandbox Code Playgroud)
〜/的.config /鱼/功能/ 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
Run Code Online (Sandbox Code Playgroud)