[英]How to override fish_prompt, keeping the styles from the applied theme?
I installed fish shell, installed few themes.我安装了 fish shell,安装了几个主题。 Applied the theme "agnoster", all good is pretty but I want fish_prompt to override the original one and keep the styles in order to show me full path properly.
应用主题“agnoster”,一切都很好,但我希望 fish_prompt 覆盖原始提示并保留 styles 以便正确显示完整路径。 Currently the full path is a shortcut such as
Desktop/Abba
turns to ~D/Abba
and I want to remove the D and will it be ~Desktop/Abba
.目前完整路径是一个快捷方式,例如
Desktop/Abba
变成~D/Abba
,我想删除 D ,它会是~Desktop/Abba
。 How can I override function fish_prompt
properly so that I am able to call the original previous function from the theme to keep up the styles?如何正确覆盖
function fish_prompt
以便我能够从主题中调用原来的前一个 function 以跟上 styles?
The agnoster theme uses fish's prompt_pwd
function to display the pwd. 无知主题使用fish的
prompt_pwd
函数显示pwd。
That shortens each path component to $fish_prompt_pwd_dir_length characters. 这样会将每个路径组成部分缩短为$ fish_prompt_pwd_dir_length个字符。 Set that variable to 0 to inhibit shortening entirely.
将该变量设置为0可完全禁止缩短。
Alternatively, you can change the prompt_pwd function however you want it, eg via funced prompt_pwd
(and funcsave prompt_pwd
once you're happy with the result). 另外,您也可以根据需要更改hint_pwd函数,例如,通过功能
funced prompt_pwd
(对结果满意后可以使用funcsave prompt_pwd
)。
I've had a similar issue, but the chosen answer didn't work for me.我遇到过类似的问题,但选择的答案对我不起作用。
In my case, I've had to source all theme files manually before overriding the fish_prompt
function.就我而言,我必须在覆盖
fish_prompt
function 之前手动获取所有主题文件。
For example例如
source $OMF_PATH/init.fish # assure omf is loaded before run the following code
# Read current theme
test -f $OMF_CONFIG/theme
and read -l theme < $OMF_CONFIG/theme
or set -l theme default
set -l theme_functions_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme/functions/
for conf in $theme_functions_path/*.fish
source $conf
end
function fish_prompt
# prompt_theme_foo
# prompt_theme_bar
end
More details on: https://stackoverflow.com/a/72098697/2180456更多详情: https://stackoverflow.com/a/72098697/2180456
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.