Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix completion if word-to-complete contains colon (:) #9

Merged
merged 1 commit into from

3 participants

@raducu

The recommended way to handle colons in completion words
is by using the helper methods:

  • _get_comp_words_by_ref with the -n : option gets the word-to-complete without considering a colon as a word break
  • __ltrim_colon_completions removes colon containing prefix from COMPREPLY items (a workaround for http://tiswww.case.edu/php/chet/bash/FAQ - E13)

Using the helper methods also simplifies the script and
ensures that we get the same behavior on any environment.

Tested on Ubuntu 12.04, Red Hat 5 and 6.

@miezuit miezuit Fix completion if word-to-complete contains colon (:)
The recommended way to handle colons in completion words
is by using the helper methods:
 * _get_comp_words_by_ref with the -n : option
      gets the word-to-complete without considering a colon as a word break
 * __ltrim_colon_completions
      removes colon containing prefix from COMPREPLY items
      (a workaround for http://tiswww.case.edu/php/chet/bash/FAQ - E13)

Using the helper methods also simplifies the script and
ensures that we get the same behavior on any environment.
f2428e5
@jaz303
Owner

Great, thank you for the fix.

@jaz303 jaz303 merged commit 605e0a3 into jaz303:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 19, 2012
  1. @miezuit

    Fix completion if word-to-complete contains colon (:)

    miezuit authored
    The recommended way to handle colons in completion words
    is by using the helper methods:
     * _get_comp_words_by_ref with the -n : option
          gets the word-to-complete without considering a colon as a word break
     * __ltrim_colon_completions
          removes colon containing prefix from COMPREPLY items
          (a workaround for http://tiswww.case.edu/php/chet/bash/FAQ - E13)
    
    Using the helper methods also simplifies the script and
    ensures that we get the same behavior on any environment.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 7 deletions.
  1. +2 −7 phake_completion.sh
View
9 phake_completion.sh
@@ -4,19 +4,14 @@ _phake()
COMPREPLY=()
local cur prev
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
+ _get_comp_words_by_ref -n : cur prev
local opts
opts=`phake -T | awk 'BEGIN {x=1}; $x>1 {print $1}'`
- optscolon=${cur%"${cur##*:}"}
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}))
- local i=${#COMPREPLY[*]}
- while [ $((--i)) -ge 0 ]; do
- COMPREPLY[$i]=${COMPREPLY[$i]#"$optscolon"}
- done
+ __ltrim_colon_completions "$cur"
}
complete -F _phake phake
Something went wrong with that request. Please try again.