鱼互动壳全路径

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)

Ami*_*far 39

使用新的fishshell(v2.3)你可以做到set -U fish_prompt_pwd_dir_length 0.它将使用完整的路径.我也用dartfish作为我的主题.见下面的例子:

在此输入图像描述


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此操作在将来的会话中保持不变.

  • 你实际上并不需要`if`,在主目录中,`sed`仍会产生`~` (3认同)

ryn*_*nop 6

我个人不喜欢触摸共享/默认值.鱼有很棒的功能设计,所以杠杆化.

~/.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)