Zsh: debugging git remotes completion
I spend most of my day in a linux terminal (KDE's konsole), doing so, I interact directly with git.
I usually starts working on a topic:
# 'co' is an alias for checkout
# I create a new branch
Then, I work intensively and I conclude by adding my changes in a commit
# I stage each chuncks
Finally, I want to push by branch:
I try to trigger zsh's git completion, but after several seconds, I've got an unfortunate:
)
Going deeper, it looks like NSFW domains I have populated in my /etc/hosts
with blocked hosts from StevenBlack's hosts.
So, it breaks my flow, and does not give me relevant results.
In order to fix that, I have to limit completion to actual registered remotes.
First, I had to locate the completion function:
Mmh, it does not look good, I had to pull, well, to fetch the tarball, the relevant functions are the following:
# zsh-5.9/Completion/Unix/Command/_git
||
||
||
||
The entry-point is __git_any_repositories
which relies (_alternative
) on three functions:
__git_local_repositories
which looks-up for my folders__git_remotes
which relies ongit remote
, what I want__git_remote_repositories
which actually pulls my/etc/hosts
Thankfully with the syntax:
||
the function is only defined when it wasn't defined previously, such as in my ~/.zshrc
:
which grive me the expected behavior: