현재 디렉토리 아래의 하위 디렉토리에서 cat **/foo<TAB>
일치하는 첫 번째 파일을 일치시키고 완료하기 위해 zsh 탭 완성을 어떻게 얻습니까 ?foo*
예를 들어, 새로운 테스트 디렉터리 내에서 다음을 수행합니다. (역시, 이것은 zsh입니다)
% mkdir aaa bbb ccc
% touch aaa/foo bbb/foo ccc/foo
% cat **/f<TAB>
마지막 줄을 쳤을 때 내가 원하는 것은 <TAB>
화면이 다음과 같이 나타나는 것입니다.
% cat aaa/foo_ # filled in the first match; "_" is the cursor
aaa/foo bbb/foo ccc/foo # and here is the list of all matches
시도했지만 setopt GLOB_COMPLETE
원하는 대로 되지 않았습니다.
답변1
파일 에 다음을 추가 ~/.zshrc
하거나 명령줄에 붙여넣어 사용해 보세요.
# Load Zsh's new completion system.
autoload -Uz compinit && compinit
# Bind Tab to complete-word instead of
# expand-or-complete. This is required for
# the new completion system to work
# correctly.
bindkey '^I' complete-word
# Add the _match completer.
# We add it after _expand & _complete, so it
# will get called only once those two have
# failed.
# _match_ completes patterns only, which
# _expand can do, too, (which is why we call
# _match_ only when _expand & _complete
# fail), but _match adds an extra * at the
# cursor position. Without that, the pattern
# **/f would not match {aaa,bbb,ccc}/foo
zstyle ':completion:*' completer \
_expand _complete _match _ignored
# Let all possible completions for a partial
# path be listed, rather than just the first
# one.
zstyle ':completion:*' list-suffixes true
그런 다음 을 입력 cat **/f
하고 키를 누르면 Tab다음과 같은 출력이 표시됩니다.
% cat aaa/foo
aaa/foo bbb/foo ccc/foo
**/f
선적 서류 비치:
또한보십시오:Z-Shell 사용자 가이드: 완성, 기존 및 신규