zsh로 git complete : 공백이있는 파일 이름이 올바르게 이스케이프되지 않습니다 삽입되지 않습니다. 이름에 공백이있는 파일 이름을 입력하면

힘내 완료 :

내 시스템에서 git의 파일 이름 자동 완성에 어려움을 겪고 있습니다. OS X (10.9.3)에서 (1.9.3) zsh과 함께 (5.0.5)를 사용하고 git있습니다. 모두 zshgit사제를 통해 설치되었습니다. (전체 버전 출력은 게시물 하단에 있습니다.)

git의 파일 이름 완성에 예상대로 공백이 삽입되지 않습니다. 이름에 공백이있는 파일 이름을 입력하면 쉘은 공백을 이스케이프하지 않고 파일 이름을 삽입합니다. zsh내장 완료는이 작업을 수행하지 않지만 수행합니다 git.

여기 내가보고있는 예가 있습니다.

이름에 공백이있는 몇 개의 파일이있는 저장소가 있습니다.

% ls -la
test
test four - latest.txt
test three.txt
test two

셸 백 슬래시는 탭 완성을 사용하여 파일 이름을 삽입 할 때 예상대로 파일 이름을 이스케이프 처리합니다.

% echo "testing" >> test<tab>

탭을 세 번 누르면 자동 완성됩니다.

% echo "testing" >> test\ four\ -\ latest.txt
––– file
test                       test\ four\ -\ latest.txt  test\ three.txt            test\ two                

git status 이 파일 이름을 따옴표로 표시합니다 (무슨 일인지 이해합니다).

% git status --short
 M test
 M "test four - latest.txt"
 M "test three.txt"
 M "test two"

그러나 git add탭 자동 완성을 시도하면 옆으로 진행됩니다.

% git add test<tab>

탭을 세 번 누른 후 결과 :

% git add test four - latest.txt
test                    test four - latest.txt  test three.txt          test two

나는이 약간의 기능에 영향을 미치지 시도했다 : 나는 시도했다 그래서 나의 dotfiles는 버전 제어에 zsh 4.3.15, git 1.8.3나는 거의 확신 할 때, 1 년 전부터 나의 dotfiles이했다. 이상하게도이 설정은 여전히 ​​깨졌습니다.

나는 까지를 좁혀 _git에서 공급되고 완성 파일 /usr/local/share/zsh/site-functions:

% echo $FPATH
/usr/local/share/zsh/site-functions:/usr/local/Cellar/zsh/5.0.5/share/zsh/functions
% ls -l /usr/local/share/zsh/site-functions
_git@ -> ../../../Cellar/git/1.9.3/share/zsh/site-functions/_git
_hg@ -> ../../../Cellar/mercurial/3.0/share/zsh/site-functions/_hg
_j@ -> ../../../Cellar/autojump/21.7.1/share/zsh/site-functions/_j
git-completion.bash@ -> ../../../Cellar/git/1.9.3/share/zsh/site-functions/git-completion.bash
go@ -> ../../../Cellar/go/HEAD/share/zsh/site-functions/go

달리기 $FPATH전에 수동으로 변경 하거나 단순히 심볼릭 링크 를 제거하면 완료가 다시 예상대로 작동합니다..zshrccompinit/usr/local/share/zsh/site-functions/_gitzsh

zsh완료하지 않고 _git:

% git add test<tab>

탭을 세 번 누르면 올바른 결과가 생성됩니다.

% git add test\ four\ -\ latest.txt
––– modified file
test                       test\ four\ -\ latest.txt  test\ three.txt            test\ two                

참고 사항 : git-completion.bash링크를 제거하려고 시도했지만 완전히 중단됩니다.

% git add test<tab>

이 파열됨을 생성합니다.

% git add test__git_zsh_bash_func:9: command not found: __git_aliased_command
    git add test
––– file
test                       test\ four\ -\ latest.txt  test\ three.txt            test\ two                

나는 정말 의 나머지 부분이 제대로 작동을하고 싶지 _git그들은 더 많은 REPO 인식 댄이기 때문에 완료가 대단 zsh사람,하지만 난 공백이나 특수 문자가 포함 된 파일 이름이 제대로 이스케이프해야합니다.


소프트웨어 버전 :

% zsh --version
zsh 5.0.5 (x86_64-apple-darwin13.0.0)

% git --version
git version 1.9.3

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.9.3
BuildVersion:   13D65

내가 업로드 한 _gitgit-completion.bash파일 : 자식-completion.bash_git (로 변경 _git.sh. CloudApp는 브라우저에서 볼 수 있도록 않도록를)



답변

이 버그는 메일 링리스트 에 언급되어 있습니다.

수정은에서 파일을 편집하고 git-completion.zsh에서 -Q옵션을 제거하는 것 compadd입니다 __gitcomp_file.

--- i/contrib/completion/git-completion.zsh
+++ w/contrib/completion/git-completion.zsh
@@ -90,7 +90,7 @@ __gitcomp_file ()

    local IFS=$'\n'
    compset -P '*[=:]'
-   compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
+   compadd -p "${2-}" -f -- ${=1} && _ret=0
 }

 __git_zsh_bash_func ()

이 파일은 contrib/completion디렉토리 에서 설치되며 경로는 패키지 관리자에 따라 다를 수 있습니다. macOS에 homebrew와 함께 설치 한 경우에 있습니다 /usr/local/Cellar/git/2.10.2/share/zsh/site-functions.


답변