2

我在使用 bash_completion 时遇到问题。当我扩展变量时,我很好,但是当我使用命令完成(例如gitor vim-addon-manager)时,完成会在其中抛出随机字符。我以前没有发生过这种情况,我无法弄清楚它是什么。

这是我键入时发生的示例gitTabTaby

[11:11] me@my_computer:~ $ git
Display all 131 possibilities? (y or n)
^[[01;31m^[[K                    c^[[m^[[Kheckout                 delete-tag                       f^[[m^[[Kmt-merge-msg            i^[[m^[[Knit-db                  notes                            rm
a^[[m^[[Kdd                      c^[[m^[[Kheckout-index           d^[[m^[[Kaemon                   f^[[m^[[Kor-each-ref             i^[[m^[[Knstaweb                 obliterate                       setup
a^[[m^[[Klias                    c^[[m^[[Kheck-ref-format         d^[[m^[[Kelete-branch            f^[[m^[[Kormat-patch             info                             p4                               shortlog
a^[[m^[[Km                       c^[[m^[[Kherry                   d^[[m^[[Kelete-merged-branches   f^[[m^[[Ksck                     line-summary                     pull                             show
a^[[m^[[Knnotate                 c^[[m^[[Kherry-pick              d^[[m^[[Kelete-submodule         f^[[m^[[Ksck-objects             l^[[m^[[Kog                      pull-request                     show-branch
a^[[m^[[Kpply                    c^[[m^[[Klean                    d^[[m^[[Kescribe                 fresh-branch                     l^[[m^[[Ks-files                 push                             show-tree
a^[[m^[[Krchive                  c^[[m^[[Klone                    d^[[m^[[Kiff                     g^[[m^[[Kc                       l^[[m^[[Ks-remote                rebase                           squash
a^[[m^[[Krchive-file             c^[[m^[[Kolumn                   d^[[m^[[Kiff-files               g^[[m^[[Ket-tar-commit-id        l^[[m^[[Ks-tree                  refactor                         stage
b^[[m^[[Kack                     c^[[m^[[Kommit                   d^[[m^[[Kiff-index               g^[[m^[[Krep                     local-commits                    reflog                           stash
b^[[m^[[Kisect                   c^[[m^[[Kommits-since            d^[[m^[[Kifftool                 graft                            mergetool                        release                          status
b^[[m^[[Klame                    c^[[m^[[Kommit-tree              d^[[m^[[Kiff-tree                h^[[m^[[Kash-object              m^[[m^[[Kailinfo                 relink                           submodule
b^[[m^[[Kranch                   c^[[m^[[Konfig                   effort                           h^[[m^[[Kelp                     m^[[m^[[Kailsplit                remote                           subtree
b^[[m^[[Kug                      c^[[m^[[Kontrib                  extras                           h^[[m^[[Kttp-backend             m^[[m^[[Kerge                    rename-tag                       summary
b^[[m^[[Kundle                   c^[[m^[[Kount                    feature                          h^[[m^[[Kttp-fetch               m^[[m^[[Kerge-base               repack                           tag
c^[[m^[[Kat-file                 c^[[m^[[Kount-objects            f^[[m^[[Kast-export              h^[[m^[[Kttp-push                m^[[m^[[Kerge-file               repl                             touch
c^[[m^[[Khangelog                c^[[m^[[Kreate-branch            f^[[m^[[Kast-import              ignore                           m^[[m^[[Kerge-index              replace                          undo
c^[[m^[[Kheck-attr               c^[[m^[[Kredential               f^[[m^[[Ketch                    i^[[m^[[Kmap-send                m^[[m^[[Kerge-octopus            request-pull                     whatchanged
c^[[m^[[Kheck-ignore             c^[[m^[[Kredential-cache         f^[[m^[[Ketch-pack               i^[[m^[[Kndex-pack               mv                               reset
c^[[m^[[Kheck-mailmap            c^[[m^[[Kredential-store         f^[[m^[[Kilter-branch            i^[[m^[[Knit                     name-rev                         revert


另一个例子是vam tetris( vam tetTabTab):

^[[01;31m^[[Kaddon:  tet^[[m^[[Kris


因为vam install tetTabTab,它实际上使它成为一个无效的参数(它也很难阅读),那么我该如何解决这个问题呢?

4

2 回答 2

1

显然,bash 补全不喜欢何时grep着色。任何像

alias grep='grep --color=always'
alias fgrep='fgrep --color=always'
alias egrep='egrep --color=always'

会给你带来问题。

因此,正如 Garrett Bellomy 在下面详述的那样,使用 可能是明智之举--color=auto,这可以通过设置(或通过在rc文件GREP_OPTIONS中为 grep 别名)来实现。如果您想将其设为全局变量,请将其添加到~/.bash_profile (for bash) 或~/.zprofile (zsh),具体取决于您的默认 shell:export GREP_OPTIONS='--color=auto'

于 2015-06-18T20:52:30.647 回答
1

I was experiencing the same problem and saw your answer and changed:

export GREP_OPTIONS='--color=always'
to
export GREP_OPTIONS='--color=auto'
This seems to have fixed the problem with bash-completion on my Mac.

于 2017-04-04T17:33:34.840 回答