首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fish Interactive Shell完整路径

Fish Interactive Shell完整路径
EN

Stack Overflow用户
提问于 2009-05-15 04:34:33
回答 6查看 12.3K关注 0票数 37

在Fish Interactive shell中是否有一种方法可以显示完整的路径。目前,当我导航到一个目录时,我得到了以下shell。

代码语言:javascript
复制
millermj@Dodore ~/o/workspace

但我宁愿看到

代码语言:javascript
复制
millermj@Dodore ~/o-town/workspace
EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2016-05-20 11:47:58

使用新的fishshell (v2.3),您可以执行set -U fish_prompt_pwd_dir_length 0。它将使用完整路径。我也使用dartfish作为我的主题。如下例所示:

票数 49
EN

Stack Overflow用户

发布于 2010-04-06 02:31:06

以下是我的prompt_pwd版本,它应该会显示您正在查找的内容:

代码语言:javascript
复制
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使该行为在以后的会话中保持不变。

票数 17
EN

Stack Overflow用户

发布于 2014-11-01 04:14:10

我个人不喜欢接触共享/默认设置。Fish有一个很棒的函数设计,所以要充分利用它。

创建包含以下内容的~/.config/fish/functions/prompt_long_pwd.fish

代码语言:javascript
复制
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

代码语言:javascript
复制
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

代码语言:javascript
复制
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
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/866989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档