diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-01 13:15:28 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-01 13:15:28 +1300 |
commit | b6c540ded9a527f19b8bff7888e330ba2786f552 (patch) | |
tree | 2fdddfb9844127ee20be21b83e6fb4c749328588 /bash/bash_completion.d/git.bash | |
parent | Overhaul bd() completion again (diff) | |
download | dotfiles-b6c540ded9a527f19b8bff7888e330ba2786f552.tar.gz dotfiles-b6c540ded9a527f19b8bff7888e330ba2786f552.zip |
Use the positional parameter aliases for words
The current word is available in $2, and the previous word in $3. That's
easier (and maybe a bit less expensive) to dig out, so let's use it.
Diffstat (limited to 'bash/bash_completion.d/git.bash')
-rw-r--r-- | bash/bash_completion.d/git.bash | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bash/bash_completion.d/git.bash b/bash/bash_completion.d/git.bash index a2edb468..a05655c3 100644 --- a/bash/bash_completion.d/git.bash +++ b/bash/bash_completion.d/git.bash @@ -15,7 +15,7 @@ _git() { ref=${ref#refs/*/} case $ref in '') continue ;; - "${COMP_WORDS[COMP_CWORD]}"*) + "$2"*) COMPREPLY[${#COMPREPLY[@]}]=$ref ;; esac @@ -29,7 +29,7 @@ _git() { while IFS= read -r remote ; do case $remote in '') continue ;; - "${COMP_WORDS[COMP_CWORD]}"*) + "$2"*) COMPREPLY[${#COMPREPLY[@]}]=$remote ;; esac @@ -45,7 +45,7 @@ _git() { alias=${alias%% *} case $alias in '') continue ;; - "${COMP_WORDS[COMP_CWORD]}"*) + "$2"*) COMPREPLY[${#COMPREPLY[@]}]=$alias ;; esac @@ -58,7 +58,7 @@ _git() { local execpath execpath=$(git --exec-path) || return local path - for path in "$execpath"/git-"${COMP_WORDS[COMP_CWORD]}"* ; do + for path in "$execpath"/git-"$2"* ; do ! [[ -d $path ]] || continue [[ -e $path ]] || continue [[ -x $path ]] || continue @@ -121,7 +121,7 @@ _git() { set-url show update - ' -- "${COMP_WORDS[COMP_CWORD]}") + ' -- "$2") else "${FUNCNAME[0]}" remotes fi @@ -146,7 +146,7 @@ _git() { save show store - ' -- "${COMP_WORDS[COMP_CWORD]}") + ' -- "$2") return ;; @@ -166,7 +166,7 @@ _git() { summary sync update - ' -- "${COMP_WORDS[COMP_CWORD]}") + ' -- "$2") return ;; @@ -187,7 +187,7 @@ _git() { # I normally only want a refspec for "reset" if I'm using the --hard or # --soft option; otherwise, files are fine reset) - case ${COMP_WORDS[COMP_CWORD-1]} in + case $3 in --hard|--soft) "${FUNCNAME[0]}" refs ;; |