Fish Interactive Shell 完整路径
Fish Interactive shell 中有没有办法显示完整路径。 目前,当我导航到目录时,我会得到以下 shell。
millermj@Dodore ~/o/workspace
但我宁愿看到
millermj@Dodore ~/o-town/workspace
Is there a way in the Fish Interactive shell for the full path to be displayed. Currently when I navigate to a directory I get the following shell.
millermj@Dodore ~/o/workspace
but I would rather see
millermj@Dodore ~/o-town/workspace
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
使用新的fishshell (v2.3),您可以执行
set -U Fish_prompt_pwd_dir_length 0
。 并且它将使用完整路径。 我还使用 dartfish 作为我的主题。 请参阅下面的示例:With the new fishshell (v2.3) you can do
set -U fish_prompt_pwd_dir_length 0
. And it will use the full path. I also use dartfish for my theme. See example below:这是我的
prompt_pwd
版本,它应该显示您要查找的内容:这将像往常一样显示主目录的波浪号,但删除了仅拉取的
sed
命令当您深入几个目录时,每个目录的第一个字母。要编辑
prompt_pwd
,请使用funced
。 它将允许您交互地更改功能。 从命令行输入funced提示_pwd
。 根据您的喜好显示提示后,请使用funcsaveprompt_pwd
使该行为在以后的会话中持续存在。Here's my version of
prompt_pwd
that should display what you're looking for:This will display the tilde for the home directory, as usual, but removes the
sed
command that only pulls the first letter from each directory when you're a few directories deep.To edit
prompt_pwd
usefunced
. It will allow you to interactively alter the function. From the command line typefunced prompt_pwd
. Once the prompt is displaying to your liking, usefuncsave prompt_pwd
to make the behavior persist in future sessions.我个人不喜欢触及共享/默认值。 Fish 具有出色的功能设计,因此请充分利用它。
使用以下内容创建
~/.config/fish/functions/prompt_long_pwd.fish
:然后只需编辑
~/.config/fish/functions/fish_prompt.fish
以使用 <代码>prompt_long_pwd。 这是我使用的自定义提示:~/.config/fish/config.fish:
~/.config/fish/functions/fish_prompt.fish
I personally don't like touching the shared/defaults. Fish has a great functions design, so leverage that.
Create
~/.config/fish/functions/prompt_long_pwd.fish
with the contents:Then simply edit your
~/.config/fish/functions/fish_prompt.fish
to useprompt_long_pwd
. Here is the custom prompt that I use:~/.config/fish/config.fish:
~/.config/fish/functions/fish_prompt.fish
创建
~/.config/fish/functions/prompt_long_pwd.fish
:在
~/.config/fish/functions/fish_prompt.fish
中更改(prompt_pwd) ( set_color 正常)
到(prompt_long_pwd) (set_color 正常)
。(prompt_pwd)
用目录的第一个字母替换目录名称,有时我也觉得这很烦人。 你也可以修改原来的命令prompt_pwd
,我没有尝试过。此答案是根据之前的答案修改的,并显示完整目录,同时保留默认提示的其他部分。 关键的变化在于
~/.config/fish/functions/prompt_long_pwd.fish
中的表达式。Create
~/.config/fish/functions/prompt_long_pwd.fish
with:In
~/.config/fish/functions/fish_prompt.fish
change(prompt_pwd) (set_color normal)
to(prompt_long_pwd) (set_color normal)
.(prompt_pwd)
replaces the directory name with the first letter of the directory, which I too sometimes find annoying. You can also probably modify the original commandprompt_pwd
, I have not tried it.This answer is modified from the earlier answer and shows the full directory while keeping the other parts of the default prompt. The key change is in the expression in
~/.config/fish/functions/prompt_long_pwd.fish
.只是想如果您偶然发现这一点并且您的鱼没有响应
fish_prompt_pwd_dir_length
变量,请尝试升级 omf,然后更新您正在使用的 omf 主题,我想提醒大家。 然后执行一些组合操作,选择不同的主题,重新打开外壳,然后再次选择不同的主题。 这对我有用。 祝你好运!Just thought I'd give everyone a heads up if you stumbled on this and your fish is not responding to the
fish_prompt_pwd_dir_length
variable try upgrading omf, and then update your omf themes that you're using. Then do some combination of selecting a different theme, reopening the shell, and selecting a different theme again. This is what worked for me. Good luck!prompt_pwd
函数确定要显示的函数。 您应该能够编写自己的版本来获得您想要的内容。The
prompt_pwd
function determines the function to be displayed. You should be able to write your own version to get what you want.