如何从OMF主题中覆盖fish_prompt函数
我浪费了一些时间,所以我创建了这个Q& a。
我正在使用一个OMF主题,我想改变主题提示。不幸的是,我想做的更改是不可能通过设置主题配置变量来实现的。
我尝试使用funced Fish_prompt编辑
,但是如果我这样做,则不再加载主题,因此我无法使用主题中定义的功能。如果我只在我的config.fish中创建fish_prompt
函数; funcsave fish_promptfish_prompt
函数,也会发生同样的情况。
I lost some time on it so I'm creating this Q&A.
I'm using an omf theme and I would like to make a change in the theme prompt. Unfortunately, the change I want to do is not possible by setting the theme config variables.
I tried to edit fish_prompt
function using funced fish_prompt; funcsave fish_prompt
but if I do so the theme is not loaded anymore so I can't use the functions defined within the theme. The same happens if I just create a fish_prompt
function in my config.fish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
时, tldr
在定义自己的
fish_prompt
函数说明
添加这些行添加这些行,当加载OMF时,它将主题函数文件添加到
$ fish_function_path_path
。 ( source code )根据 fish document
文档没有明确说的是是否已经定义了该函数(例如,在Config.Fish中),它不会尝试从
$ fish_function_path
加载。因此,问题是,当您创建自己的
fish_prompt
函数时,它会阴影.../< theme>/functions/fish_prompt.fish.fish.fish
。您需要做的工作是在重新定义它之前强制加载主题功能文件。
例如:
请确保在OMF init.fish加载后将其运行。
您可以通过手动
来源来确保,源$ omf_path/init.fish
,或确保omf.fish.fish
的字母顺序比您的文件要小。tldr
add these lines before you define your own
fish_prompt
functionexplanation
When omf is loaded, it add the theme functions files to the
$fish_function_path
. (source code)According to fish documentation
What the documentation doesn't explicitly say is if the function is already defined (in config.fish, for example) it will not try to load from
$fish_function_path
.So the issue is, when you creates your own
fish_prompt
function, it shadows the.../<theme>/functions/fish_prompt.fish
.What you need to do to work around it is force loading the theme function file before you redefine it.
For example:
Be sure to run it after omf init.fish is loaded.
You can assure by sourcing omf manually
source $OMF_PATH/init.fish
or be sureomf.fish
is in an alphabetical order lesser than your file.