As a follow up to this question, I asked myself if it would be possible to tell git to provide it's autocomplete feature (branches etc.) for further commands, in particular plumbing commands like update-ref
.
Although update-ref
provides more flexibility than branch -f
, it's quite a hassle to use since you always have to type the full reference name. Which in turn doesn't make me want to use it.
Any ideas on this?
It is possible to enable the plumbing commands but you will need to provide some of the implementation yourself.
Find the git-completion.sh
script you are using.
In my /users/andrewc/.bashrc
I have
# GIT STUFF
if [ -f ~/.git-completion.bash ]
then
. ~/.git-completion.bash
fi
So I pull up /users/andrewc/git-completion.bash
Find the function __git_list_porcelain_command())
and comment out the line for update-ref
#update-ref) : plumbing;;
This will allow update-ref
itself to autocomplete. The script won't know how to fill in any of the args to update-ref
though. It looks like you will need to provide an implementation for __git_update_ref
to achieve this. I would use a similar command (`__git_branch maybe) as a template and go from there.