Zsh: debugging git remotes completionGautier DI FOLCO May 31, 2023 [dev] #dev #development #flow #tools #zsh #git
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_repositorieswhich looks-up for my folders
__git_remoteswhich relies on
git remote, what I want
__git_remote_repositorieswhich actually pulls my
Thankfully with the syntax:
the function is only defined when it wasn't defined previously, such as in my
which grive me the expected behavior: