Created
December 5, 2017 16:21
-
-
Save apiv/5c5bdc79c9313a309824d4a2ae47e627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tab complete for ./git-merge-pr script | |
__git-merge-pr-complete() | |
{ | |
local cur_word prev_word branch_list | |
# COMP_WORDS is an array of words in the current command line. | |
# COMP_CWORD is the index of the current word (the one the cursor is | |
# in). So COMP_WORDS[COMP_CWORD] is the current word; we also record | |
# the previous word here, although this specific script doesn't | |
# use it yet. | |
cur_word="${COMP_WORDS[COMP_CWORD]}" | |
prev_word="${COMP_WORDS[COMP_CWORD-1]}" | |
# Ask git to generate a list of branches | |
branch_list=`git branch --list | cut -c 3-` | |
COMPREPLY=( $(compgen -W "${branch_list}" -- ${cur_word}) ) | |
return 0 | |
} | |
git-merge-pr() | |
{ | |
bash ./git-merge-pr $1 | |
} | |
# Register _pss_complete to provide completion for the following commands | |
complete -F __git-merge-pr-complete git-merge-pr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment