如何覆盖 fish_prompt,保持应用主题的样式?
How to override fish_prompt, keeping the styles from the applied theme?
我安装了 fish shell,安装了几个主题。应用了主题 "agnoster",一切都很好,但我希望 fish_prompt 覆盖原始主题并保留样式,以便正确显示完整路径。目前全路径是一个快捷方式比如Desktop/Abba
转~D/Abba
我想去掉D会不会是~Desktop/Abba
。我怎样才能正确覆盖 function fish_prompt
以便我能够从主题中调用原来的 previous 函数来保持样式?
agnoster主题使用fish的prompt_pwd
函数显示pwd
这会将每个路径组件缩短为 $fish_prompt_pwd_dir_length 个字符。将该变量设置为 0 以完全禁止缩短。
或者,您可以根据需要更改 prompt_pwd 函数,例如通过 funced prompt_pwd
(和 funcsave prompt_pwd
一旦您对结果感到满意)。
我遇到过类似的问题,但选择的答案对我不起作用。
就我而言,在覆盖 fish_prompt
函数之前,我必须手动获取所有主题文件。
例如
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
更多详情:
我安装了 fish shell,安装了几个主题。应用了主题 "agnoster",一切都很好,但我希望 fish_prompt 覆盖原始主题并保留样式,以便正确显示完整路径。目前全路径是一个快捷方式比如Desktop/Abba
转~D/Abba
我想去掉D会不会是~Desktop/Abba
。我怎样才能正确覆盖 function fish_prompt
以便我能够从主题中调用原来的 previous 函数来保持样式?
agnoster主题使用fish的prompt_pwd
函数显示pwd
这会将每个路径组件缩短为 $fish_prompt_pwd_dir_length 个字符。将该变量设置为 0 以完全禁止缩短。
或者,您可以根据需要更改 prompt_pwd 函数,例如通过 funced prompt_pwd
(和 funcsave prompt_pwd
一旦您对结果感到满意)。
我遇到过类似的问题,但选择的答案对我不起作用。
就我而言,在覆盖 fish_prompt
函数之前,我必须手动获取所有主题文件。
例如
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
更多详情: