zsh はタグ順一致パターンを完成します。

zsh はタグ順一致パターンを完成します。

利用可能ですか?パターンマッチignored-patterstag-order

次のように、最初の試みでプレフィックスなしで限られた一致完了のカスタムセットを試したいと思います。

$ man <Tab>
man info zshall

これは単純化された例です。私はgitでも同じことをしたいです。私の現在のスタイルは、無視する特定のエイリアスまたはコマンドパラメータのセットに依存していますが、これは理想的ではありません。

zstyle ':completion:*:complete:git:*' force-list  always
zstyle ':completion:*:complete:git:*' tag-order \
  'main-porcelain-commands:-freq:frequently\ used\ commands aliases'
zstyle ':completion:*:complete:git:*:main-porcelain-commands-freq' \
  ignored-patterns '(am|archive|bisect|bundle|clean|cherry-pick|citool|fetch|gc|gui|ls-files|log|notes|range-diff|show|stash|status|submodule|subtree|worktree)*'

これは次のことを示します。

$ git <Tab>
add                -- add file contents to index
ai                 -- alias for 'add --interactive'
amend              -- alias for 'commit --amend --reuse-message=HEAD'
branch             -- list, create, or delete branches
checkout           -- checkout branch or paths to working tree
clone              -- clone repository into new directory
commit             -- record changes to repository
ctags              -- alias for '!.git/hooks/ctags'
describe           -- show most recent tag that is reachable from a commit
df                 -- alias for 'diff --staged'
diff               -- show changes between commits, commit and working tree, etc.
format-patch       -- prepare patches for e-mail submission
graph              -- alias for 'log --graph --oneline --decorate'
grep               -- print lines matching a pattern
init               -- create empty git repository or re-initialize an existing one
ls                 -- alias for 'ls-files'
merge              -- join two or more development histories together
mv                 -- move or rename file, directory, or symlink
pull               -- fetch from and merge with another repository or local branch
push               -- update remote refs along with associated objects
rebase             -- forward-port local commits to the updated upstream head
res                -- alias for 'reset --soft HEAD^'
reset              -- reset current HEAD to specified state
revert             -- revert existing commits
rm                 -- remove files from the working tree and from the index
shortlog           -- summarize git log output
st                 -- alias for 'status --short --untracked-files=no'
tag                -- create, list, delete or verify tag object signed with GPG

すべてを無視して使用する必要があるのかfake-always​​、で否定検索を使用できるのか、それともignored-patternsシステムに実際に存在するいくつかのマニュアルページを選択して自動的に使用するためにカスタム完了関数を書く必要があるのか​​どうか疑問に思います。まず、ラベルを定義してください。

ベストアンサー1

以下で否定的な照会を実行できますignored-patterns。単一パターンを使用して、次を使用します。^否定演算子。 (extended_glob完了中は常に有効になりますが、setopt extended_glob完了後も便利ですので、とにかくお勧めします。)

zstyle ':completion:*:complete:git:*:main-porcelain-commands-freq' \
  ignored-patterns '^(add|branch|…)'

おすすめ記事