TIDE 内的 Fish shell git 提示符

标签 fish

是否可以强制Fish shell扩展TIDE到 使用fish_git_prompt而不是它自己的_tide_item_git.fish

我的目标是使 TIDE git 提示符与此 tutorial 相同.

现在使用默认的 TIDE 设置,我有这个 git 提示:

enter image description here

但是,我想让它看起来像这样,但仍然使用TIDE:

enter image description here Source image


fish ,版本3.2.1

Fedora 33

最佳答案

所以,tide 函数的作用就是简单地收集 git 信息并打印它。 Tide 调用它,获取它打印的内容,并将其放在正确的位置。这也是 Fish_git_prompt 的工作原理 - 它打印 git 内容,你的提示符负责将其放在正确的位置。

简化:

function fish_prompt
    set gitstuff (_tide_item_git)
    # do other tide stuff
    printf '%s' $gitstuff $otherstuff
end

当fish调用函数时,它会通过$fish_function_path查找具有函数名称(加上“.fish”后缀)的文件。

因此,您只需创建自己的函数 _tide_item_git,并将其放在 $fish_function_path 的首位。

我不确定你是如何安装的,我假设它不是直接在 ~/.config/fish/functions - 你的函数的正常目录中。这是一个简单的情况,因此您只需调用 funced _tide_item_git,它将在编辑器中打开它,并将其替换为

function _tide_item_git
    fish_git_prompt
end

一旦你满意,就运行funcsave _tide_item_git

在更复杂的情况下,为您的函数创建另一个目录 - ~/.config/fish/myfunctions 也许 - 将其添加到 $fish_function_path:

set -g fish_function_path ~/.config/fish/myfunctions $fish_function_path

(将其放入 config.fish)

在那里创建一个名为_tide_item_git.fish的文件并将上述函数放入其中。

关于TIDE 内的 Fish shell git 提示符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66857611/

相关文章:

shell - fish shell 中的通用变量存储在哪里?

java - 为什么从 Fish 运行时 Maven 使用错误的 JDK 版本?

git - 使用 && 的 Fishshell 别名

linux - 如何在 fish shell 中的每个 session 中永久设置 env?

node.js - fish shell nvm 告诉我 node 和 npm 是 "currently not installed"但它们是

fish - 如何在for循环中重命名fish中的文件扩展名?

fish - 如何为 fish 中的某些脚本设置临时?

shell - fish shell 错误

virtualenv - 在 Fish shell 中设置 virtualenv 名称,直接在 config.fish 中

shell - 如何使 virtualenvwrapper 在 fish shell 中工作?