Problem
I have the following
git reset HEAD^ half_entered_file_n<Tab>
At this point I would like the half_entered_file_name.txt to be Tab-completed.
My own investigation
I can get Tab completion to work if i write
git reset HEAD\^ ...
instead, escaping the "^".
Writing a "^" as the last character doesn't seem to affect autocomplete, unless HEAD is also present:
#autocomplete works
git reset RANDOM^ half_entered_file_n<Tab> #works
Zsh configuration
I am using Oh-my-zsh. On top of oh-my-zsh, i have configured the following which may be relevant:
# Let <TAB> auto completion add a slash at the end instead of space (like BASH)
zstyle ':completion:*' special-dirs true
# Unless this option is set, you can't write git checkout HEAD^^ without escaping ^ as \^ in zsh
setopt NO_NOMATCH
# Standard git plugins
plugins=(git git-extras)
For completeness, here is my configuration
I am running this on OSX in iTerm2.
Thanks!
Update
I have found some semi-solutions, but none that lead to an "answered" status yet, which basically makes them non-solutions.
- set
compdef -d git
in .zshrc as proposed by "caveman"- Solves: Now HEAD^ no longer breaks file autocompletion.
- Drawback: git command autocompletion doesn't work anymore.
- Use the accepted answer by "ralphtheninja" from this question
- Solves: Should replace the way the file completion list is generated, which would solve the problem.
- Drawback: Doesn't work. It seems git-completion.zsh/.bash has changed syntax.
I don't know shell scripting well enough to understand exactly what is going on in git-completion.zsh/.bash, and if that is the reason things are breaking.