File tree Expand file tree Collapse file tree 8 files changed +39
-28
lines changed
Expand file tree Collapse file tree 8 files changed +39
-28
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ def compgen
3030 @compgen ||= compgen!
3131 end
3232
33+ def text_without_prefix
34+ text . split ( ' ' ) [ 1 ..-1 ] . join ' '
35+ end
36+
3337 private
3438
3539 def compgen!
Original file line number Diff line number Diff line change 55# Modifying it manually is not recommended
66< %= function_name %> () {
77 local cur=${COMP_WORDS[COMP_CWORD]}
8+ local comp_line=" ${COMP_WORDS[*]: 1} "
89
9- case " $COMP_LINE " in
10+ case " $comp_line " in
1011% patterns.each do |pattern|
1112% next if pattern.empty?
12- ' <%= pattern.text %>' * ) COMPREPLY=($( compgen < %= pattern.compgen %> -- " $cur " ) ) ;;
13+ ' <%= pattern.text_without_prefix %>' * ) COMPREPLY=($( compgen < %= pattern.compgen %> -- " $cur " ) ) ;;
1314% end
1415 esac
1516}
Original file line number Diff line number Diff line change 55# Modifying it manually is not recommended
66_mygit_completions () {
77 local cur=${COMP_WORDS[COMP_CWORD]}
8+ local comp_line=" ${COMP_WORDS[*]: 1} "
89
9- case " $COMP_LINE " in
10- ' mygit status' * ) COMPREPLY=($( compgen -W " --help --verbose --branch $( git branch 2> /dev/null) " -- " $cur " ) ) ;;
11- ' mygit commit' * ) COMPREPLY=($( compgen -A file -W " --help --message --all -a --quiet -q" -- " $cur " ) ) ;;
12- ' mygit init' * ) COMPREPLY=($( compgen -A directory -W " --bare" -- " $cur " ) ) ;;
13- ' mygit ' * ) COMPREPLY=($( compgen -W " --help --version status init commit" -- " $cur " ) ) ;;
10+ case " $comp_line " in
11+ ' status' * ) COMPREPLY=($( compgen -W " --help --verbose --branch $( git branch 2> /dev/null) " -- " $cur " ) ) ;;
12+ ' commit' * ) COMPREPLY=($( compgen -A file -W " --help --message --all -a --quiet -q" -- " $cur " ) ) ;;
13+ ' init' * ) COMPREPLY=($( compgen -A directory -W " --bare" -- " $cur " ) ) ;;
14+ ' ' * ) COMPREPLY=($( compgen -W " --help --version status init commit" -- " $cur " ) ) ;;
1415 esac
1516}
1617
Original file line number Diff line number Diff line change 55# Modifying it manually is not recommended
66_mycomps () {
77 local cur=${COMP_WORDS[COMP_CWORD]}
8+ local comp_line=" ${COMP_WORDS[*]: 1} "
89
9- case " $COMP_LINE " in
10- ' mygit status' * ) COMPREPLY=($( compgen -W " --help --verbose --branch $( git branch 2> /dev/null) " -- " $cur " ) ) ;;
11- ' mygit commit' * ) COMPREPLY=($( compgen -A file -W " --help --message --all -a --quiet -q" -- " $cur " ) ) ;;
12- ' mygit init' * ) COMPREPLY=($( compgen -A directory -W " --bare" -- " $cur " ) ) ;;
13- ' mygit ' * ) COMPREPLY=($( compgen -W " --help --version status init commit" -- " $cur " ) ) ;;
10+ case " $comp_line " in
11+ ' status' * ) COMPREPLY=($( compgen -W " --help --verbose --branch $( git branch 2> /dev/null) " -- " $cur " ) ) ;;
12+ ' commit' * ) COMPREPLY=($( compgen -A file -W " --help --message --all -a --quiet -q" -- " $cur " ) ) ;;
13+ ' init' * ) COMPREPLY=($( compgen -A directory -W " --bare" -- " $cur " ) ) ;;
14+ ' ' * ) COMPREPLY=($( compgen -W " --help --version status init commit" -- " $cur " ) ) ;;
1415 esac
1516}
1617
Original file line number Diff line number Diff line change @@ -6,12 +6,13 @@ give_comps() {
66 echo $'# Modifying it manually is not recommended'
77 echo $'_mygit_completions() {'
88 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
9+ echo $' local comp_line="${COMP_WORDS[*]:1}"'
910 echo $''
10- echo $' case "$COMP_LINE " in'
11- echo $' \'mygit status\'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;'
12- echo $' \'mygit commit\'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;'
13- echo $' \'mygit init\'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;'
14- echo $' \'mygit \'*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;'
11+ echo $' case "$comp_line " in'
12+ echo $' \'status\'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;'
13+ echo $' \'commit\'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;'
14+ echo $' \'init\'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;'
15+ echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;'
1516 echo $' esac'
1617 echo $'}'
1718 echo $''
Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ send_completions() {
66 echo $'# Modifying it manually is not recommended'
77 echo $'_completely_completions() {'
88 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
9+ echo $' local comp_line="${COMP_WORDS[*]:1}"'
910 echo $''
10- echo $' case "$COMP_LINE " in'
11- echo $' \'completely generate\'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;'
12- echo $' \'completely init\'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;'
13- echo $' \'completely \'*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;'
11+ echo $' case "$comp_line " in'
12+ echo $' \'generate\'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;'
13+ echo $' \'init\'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;'
14+ echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;'
1415 echo $' esac'
1516 echo $'}'
1617 echo $''
Original file line number Diff line number Diff line change 55# Modifying it manually is not recommended
66_completely_completions () {
77 local cur=${COMP_WORDS[COMP_CWORD]}
8+ local comp_line=" ${COMP_WORDS[*]: 1} "
89
9- case " $COMP_LINE " in
10- ' completely generate' * ) COMPREPLY=($( compgen -A directory -W " --help --force" -- " $cur " ) ) ;;
11- ' completely init' * ) COMPREPLY=($( compgen -W " --help" -- " $cur " ) ) ;;
12- ' completely ' * ) COMPREPLY=($( compgen -W " --help --version init generate" -- " $cur " ) ) ;;
10+ case " $comp_line " in
11+ ' generate' * ) COMPREPLY=($( compgen -A directory -W " --help --force" -- " $cur " ) ) ;;
12+ ' init' * ) COMPREPLY=($( compgen -W " --help" -- " $cur " ) ) ;;
13+ ' ' * ) COMPREPLY=($( compgen -W " --help --version init generate" -- " $cur " ) ) ;;
1314 esac
1415}
1516
Original file line number Diff line number Diff line change 55# Modifying it manually is not recommended
66_completely_completions () {
77 local cur=${COMP_WORDS[COMP_CWORD]}
8+ local comp_line=" ${COMP_WORDS[*]: 1} "
89
9- case " $COMP_LINE " in
10- ' completely generate' * ) COMPREPLY=($( compgen -A directory -W " --help --force" -- " $cur " ) ) ;;
11- ' completely init' * ) COMPREPLY=($( compgen -W " --help" -- " $cur " ) ) ;;
10+ case " $comp_line " in
11+ ' generate' * ) COMPREPLY=($( compgen -A directory -W " --help --force" -- " $cur " ) ) ;;
12+ ' init' * ) COMPREPLY=($( compgen -W " --help" -- " $cur " ) ) ;;
1213 esac
1314}
1415
You can’t perform that action at this time.
0 commit comments