Expand git's autocomplete feature to plumbing commands
Asked Answered
C

1

4

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?

Contradance answered 7/11, 2014 at 9:32 Comment(2)
You are talking about the git-completion shell script?Perfoliate
@AndrewC I assume I am.Contradance
P
5

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.

Perfoliate answered 15/12, 2014 at 23:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.