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/path.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/path.bash')
-rw-r--r-- | bash/bash_completion.d/path.bash | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bash/bash_completion.d/path.bash b/bash/bash_completion.d/path.bash index 7143b448..8db6a74a 100644 --- a/bash/bash_completion.d/path.bash +++ b/bash/bash_completion.d/path.bash @@ -17,7 +17,7 @@ _path() { pop remove shift - ' -- "${COMP_WORDS[COMP_CWORD]}") + ' -- "$2") # Complete with either directories or $PATH entries as all other words else @@ -46,7 +46,7 @@ _path() { # Collect directory names, strip trailing slash local -a dirnames - dirnames=("${COMP_WORDS[COMP_CWORD]}"*/) + dirnames=("$2"*/) dirnames=("${dirnames[@]%/}") # Print quoted entries, null-delimited @@ -62,7 +62,7 @@ _path() { local part for part in "${promptarr[@]}" ; do case $part in - "${COMP_WORDS[COMP_CWORD]}"*) + "$2"*) COMPREPLY[${#COMPREPLY[@]}]=$(printf '%q' "$part") ;; esac |