-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I was trying to find a way of adding an autocomplete script to a subcommand but I couldn't find a way.
Reading the git-completion.bash I noticed that it has a pattern for the function names. For instance _git_stash().
So it came to me and I created the function _git_open() and it works perfectly!
This is a temporary proposal: (this is inside my .profile)
function _git_open()
{
local word=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W "$(git branch -r)" -- "${word}"))
}
complete -F _git_open git-open
The only downside so far is that it lists only remote branches.
When testing local branches with COMPREPLY=($(compgen -W "$(git branch | sed)" -- "${word}")), for some reason, it was also listing the files and directories.
Metadata
Metadata
Assignees
Labels
No labels