我最近升級了我的筆記本電腦,并一直在確保我的開發人員作業流程是我習慣的。除了 Git 選項卡自動完成之外,一切都運行良好。
通常我可以輸入git che然后點擊選項卡,它會自動完成到git checkout. 無論出于何種原因,在我的新筆記本電腦上,它都不會那樣做。現在它將列出以“che”開頭的每個選項(check-attr、check-ignore、cherry、cherry-pick 等)
我讀過一堆,但似乎無法弄清楚(a)是什么導致了這個(b)如何改變它。
規格:筆記本電腦 - Macbook Pro M1 外殼 - zsh
注意:我認為這可能與 Zsh 的tab-completion 庫有關,但不確定如何更改它。
我已閱讀檔案并更新了 zshrc 檔案
添加和刪??除:
autoload -Uz compinit && compinit
uj5u.com熱心網友回復:
有趣的問題!我調查了一下,這就是我發現的:
git 有兩個獨立的 zsh 補全系統:
與 git ( https://github.com/git/git/blob/master/contrib/completion/git-completion.zsh ) 一起提供的那個,如您鏈接的檔案中所示,提供您擁有的完成系統,基于任何可用的 git 二進制檔案。
zsh 附帶的一個(https://github.com/zsh-users/zsh/blob/master/Completion/Unix/Command/_git),它要復雜得多,而且顯然更具背景關系感知能力。
使用空zshrc( zsh -d -f -i) 開始一個新的 zsh 會話,我們會看到:
josh% autoload -Uz compinit && compinit
josh% git che<TAB>
check-attr -- display gitattributes information
check-ignore -- debug gitignore/exclude files
check-mailmap -- show canonical names and email addresses of contacts
check-ref-format -- ensure that a reference name is well formed
checkout -- checkout branch or paths to working tree
checkout-index -- copy files from index to working directory
cherry -- find commits not merged upstream
cherry-pick -- apply changes introduced by some existing commits
然后在加載另一個完成系統之后(我將在接下來討論如何執行此操作):
josh% git che<TAB>
變成
josh% git checkout
那么我們如何切換呢?我這樣做的方式是通過 OMZ 插件gitfast。我實際上并沒有(天堂禁止)使用 OMZ,而只是克隆插件并將其源到我的 fpathzshrc中fpath=( $XDG_CONFIG_HOME/ohmyzsh/plugins/gitfast $fpath )
但看起來更直接的方法是按照該_git回購中的說明進行操作:
# The recommended way to install this script is to make a copy of it as a
# file named '_git' inside any directory in your fpath.
#
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
# and then add the following to your ~/.zshrc file:
#
# fpath=(~/.zsh $fpath)
#
# You need git's bash completion script installed. By default bash-completion's
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
#
# If your bash completion script is somewhere else, you can specify the
# location in your ~/.zshrc:
#
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/526284.html
標籤:混帐终端zshzshrc
