Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Fish交互式Shell完整路径_Macos_Unix_Path_Fish - Fatal编程技术网

Macos Fish交互式Shell完整路径

Macos Fish交互式Shell完整路径,macos,unix,path,fish,Macos,Unix,Path,Fish,在Fish Interactive shell中是否有显示完整路径的方法。当前,当我导航到一个目录时,我得到以下shell millermj@Dodore ~/o/workspace 但我宁愿看到 millermj@Dodore ~/o-town/workspace prompt_pwd功能确定要显示的功能。您应该能够编写自己的版本以获得所需的内容。这是我的prompt\u pwd版本,该版本应显示您要查找的内容: function prompt_pwd --description 'Pri

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

millermj@Dodore ~/o/workspace
但我宁愿看到

millermj@Dodore ~/o-town/workspace

prompt_pwd
功能确定要显示的功能。您应该能够编写自己的版本以获得所需的内容。

这是我的
prompt\u 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
命令,该命令仅在目录较深时从每个目录中提取第一个字母


要编辑提示,请使用
functed
。它将允许您以交互方式更改功能。从命令行类型
功能提示\u pwd
。一旦提示按您的喜好显示,请使用
funcsave prompt\u pwd
在以后的会话中保持该行为。

我个人不喜欢触摸共享/默认设置。Fish的功能设计非常出色,因此要充分利用这一点


创建
~/.config/fish/functions/prompt\u long\u 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\u prompt.fish
即可使用
prompt\u long\u 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\u 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
使用新的fishshell(v2.3),您可以执行
设置-U fish\U prompt\U pwd\U dir\U length 0
。它将使用完整路径。我也用它作为我的主题。见下例:


创建
~/.config/fish/functions/prompt\u long\u pwd.fish
,其中包括:

function prompt_long_pwd --description 'Print the full working directory'
        echo $PWD
end
~/.config/fish/functions/fish\u prompt.fish中
(提示符)(设置颜色正常)
更改为
(提示符)(设置颜色正常)

(prompt\u pwd)
将目录名替换为目录的第一个字母,我有时也觉得这很烦人。您也可以修改原始命令
prompt\u pwd
,我没有尝试过


此答案由前面的修改而来,显示完整目录,同时保留默认提示的其他部分。关键的变化是
~/.config/fish/functions/prompt\u long\u pwd.fish

中的表达式,我想如果你无意中发现了这个问题,并且你的鱼没有响应
fish\u prompt\u pwd\u dir\u length
变量,我会提醒大家一声,尝试升级omf,然后更新你正在使用的omf主题。然后进行一些组合,选择不同的主题,重新打开shell,然后再次选择不同的主题。这就是我的工作。祝你好运

如果你实际上不需要
,那么在home目录中,
sed
仍然会生成
~
你的版本在我的机器上显示为
/V/Y/U/s/D/p001
而不是
卷/Yosemite I am/Users/sliplyd/Desktop/p001
(echo$PWD的结果)
。在鱼壳中键入
fish\U-config
,它将在你的浏览器中打开一个fish配置web界面。现在,您可以从一长串选项中选择提示。您的大多数答案与回答问题无关。人们希望你删除不相关的部分。我应该加上我使用的是飞镖主题。也许这是主题的一部分?不是主题的一部分。这对我来说适用于fish
2.3.1
。上面提到的命令(set-U fish\U prompt\U pwd\U dir\U length 0)可以在config.fish中配置。以防这里有人需要更多信息。