【问题标题】:In Fish, is it possible to ignore all Git related commands?在 Fish 中,是否可以忽略所有与 Git 相关的命令?
【发布时间】:2015-11-30 15:03:21
【问题描述】:

我知道 fish 不记得以 space 开头的命令,但是否可以添加忽略 Git 命令的规则?

【问题讨论】:

  • 在 bash 中,有 $HISTIGNORE。不过,我不确定鱼。
  • 我在documentation 中没有看到任何类似的内容。几乎是领先的空间。

标签: git shell fish


【解决方案1】:

灵感来自mnagle's answer,但具有特定于鱼类的功能:

如果您将gitabbreviation 添加到“git”,那么fish 会在您的每个 git 命令之前插入一个空格!

abbr -a git ' git'

【讨论】:

    【解决方案2】:

    这个 hack 怎么样:alias git=" git"

    【讨论】:

    • PS:我用 ZSH 做了这个(忽略了你问题中的鱼部分)。可能它也适用于鱼,但语法稍作调整。
    • 不会按预期工作,因为 git alias 将在历史记录中。
    【解决方案3】:

    这是一个核选项,但它可能是您的最佳选择:

    function git
        command git $argv
    
        set history_items (history --search --prefix git)
        for item in $history_items
            history --delete $item
        end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      • 2019-08-04
      • 2011-12-11
      相关资源
      最近更新 更多