File tree Expand file tree Collapse file tree 12 files changed +120
-24
lines changed Expand file tree Collapse file tree 12 files changed +120
-24
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ _mygit_completions_filter() {
1010 local result=()
1111
1212 # words the user already typed (excluding the command itself)
13- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
13+ local used=()
14+ if (( COMP_CWORD > 1 )) ; then
15+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
16+ fi
1417
1518 if [[ " ${cur: 0: 1} " == " -" ]]; then
1619 # Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mygit_completions_filter() {
3841
3942_mygit_completions () {
4043 local cur=${COMP_WORDS[COMP_CWORD]}
41- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
44+ local compwords=()
45+ if (( COMP_CWORD > 0 )) ; then
46+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
47+ fi
4248 local compline=" ${compwords[*]} "
4349
50+ COMPREPLY=()
51+
4452 case " $compline " in
4553 ' status' * ' --branch' )
4654 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mygit_completions_filter " $( git branch --format=' %(refname:short)' 2> /dev/null) " ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ _mycomps_filter() {
1010 local result=()
1111
1212 # words the user already typed (excluding the command itself)
13- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
13+ local used=()
14+ if (( COMP_CWORD > 1 )) ; then
15+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
16+ fi
1417
1518 if [[ " ${cur: 0: 1} " == " -" ]]; then
1619 # Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mycomps_filter() {
3841
3942_mycomps () {
4043 local cur=${COMP_WORDS[COMP_CWORD]}
41- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
44+ local compwords=()
45+ if (( COMP_CWORD > 0 )) ; then
46+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
47+ fi
4248 local compline=" ${compwords[*]} "
4349
50+ COMPREPLY=()
51+
4452 case " $compline " in
4553 ' status' * ' --branch' )
4654 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mycomps_filter " $( git branch --format=' %(refname:short)' 2> /dev/null) " ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ give_comps() {
1111 echo $' local result=()'
1212 echo $' '
1313 echo $' # words the user already typed (excluding the command itself)'
14- echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
14+ echo $' local used=()'
15+ echo $' if ((COMP_CWORD > 1)); then'
16+ echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
17+ echo $' fi'
1518 echo $' '
1619 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1720 echo $' # Completing an option: offer everything (including options)'
@@ -39,9 +42,14 @@ give_comps() {
3942 echo $' '
4043 echo $' _mygit_completions() {'
4144 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
42- echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
45+ echo $' local compwords=()'
46+ echo $' if ((COMP_CWORD > 0)); then'
47+ echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
48+ echo $' fi'
4349 echo $' local compline="${compwords[*]}"'
4450 echo $' '
51+ echo $' COMPREPLY=()'
52+ echo $' '
4553 echo $' case "$compline" in'
4654 echo $' \' status\' *\' --branch\' )'
4755 echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format=\' %(refname:short)\' 2>/dev/null)")" -- "$cur")'
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818 local result=()
1919
2020 # words the user already typed (excluding the command itself)
21- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
21+ local used=()
22+ if (( COMP_CWORD > 1 )) ; then
23+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
24+ fi
2225
2326 if [[ " ${cur: 0: 1} " == " -" ]]; then
2427 # Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649
4750_mygit_completions () {
4851 local cur=${COMP_WORDS[COMP_CWORD]}
49- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
52+ local compwords=()
53+ if (( COMP_CWORD > 0 )) ; then
54+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
55+ fi
5056 local compline=" ${compwords[*]} "
5157
58+ COMPREPLY=()
59+
5260 case " $compline " in
5361 ' status' * ' --branch' )
5462 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mygit_completions_filter " $( git branch --format=' %(refname:short)' 2> /dev/null) " ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818 local result=()
1919
2020 # words the user already typed (excluding the command itself)
21- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
21+ local used=()
22+ if (( COMP_CWORD > 1 )) ; then
23+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
24+ fi
2225
2326 if [[ " ${cur: 0: 1} " == " -" ]]; then
2427 # Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649
4750_mygit_completions () {
4851 local cur=${COMP_WORDS[COMP_CWORD]}
49- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
52+ local compwords=()
53+ if (( COMP_CWORD > 0 )) ; then
54+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
55+ fi
5056 local compline=" ${compwords[*]} "
5157
58+ COMPREPLY=()
59+
5260 case " $compline " in
5361 ' status' * ' --branch' )
5462 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mygit_completions_filter " $( git branch --format=' %(refname:short)' 2> /dev/null) " ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818 local result=()
1919
2020 # words the user already typed (excluding the command itself)
21- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
21+ local used=()
22+ if (( COMP_CWORD > 1 )) ; then
23+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
24+ fi
2225
2326 if [[ " ${cur: 0: 1} " == " -" ]]; then
2427 # Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649
4750_mygit_completions () {
4851 local cur=${COMP_WORDS[COMP_CWORD]}
49- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
52+ local compwords=()
53+ if (( COMP_CWORD > 0 )) ; then
54+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
55+ fi
5056 local compline=" ${compwords[*]} "
5157
58+ COMPREPLY=()
59+
5260 case " $compline " in
5361 ' status' * ' --branch' )
5462 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mygit_completions_filter " $( git branch --format=' %(refname:short)' 2> /dev/null) " ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ send_completions() {
1111 echo $' local result=()'
1212 echo $' '
1313 echo $' # words the user already typed (excluding the command itself)'
14- echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
14+ echo $' local used=()'
15+ echo $' if ((COMP_CWORD > 1)); then'
16+ echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
17+ echo $' fi'
1518 echo $' '
1619 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1720 echo $' # Completing an option: offer everything (including options)'
@@ -39,9 +42,14 @@ send_completions() {
3942 echo $' '
4043 echo $' _completely_completions() {'
4144 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
42- echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
45+ echo $' local compwords=()'
46+ echo $' if ((COMP_CWORD > 0)); then'
47+ echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
48+ echo $' fi'
4349 echo $' local compline="${compwords[*]}"'
4450 echo $' '
51+ echo $' COMPREPLY=()'
52+ echo $' '
4553 echo $' case "$compline" in'
4654 echo $' \' generate\' *)'
4755 echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")'
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ _completely_completions_filter() {
1010 local result=()
1111
1212 # words the user already typed (excluding the command itself)
13- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
13+ local used=()
14+ if (( COMP_CWORD > 1 )) ; then
15+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
16+ fi
1417
1518 if [[ " ${cur: 0: 1} " == " -" ]]; then
1619 # Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _completely_completions_filter() {
3841
3942_completely_completions () {
4043 local cur=${COMP_WORDS[COMP_CWORD]}
41- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
44+ local compwords=()
45+ if (( COMP_CWORD > 0 )) ; then
46+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
47+ fi
4248 local compline=" ${compwords[*]} "
4349
50+ COMPREPLY=()
51+
4452 case " $compline " in
4553 ' generate' * )
4654 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -A directory -W " $( _completely_completions_filter " --help --force" ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ _mygit_completions_filter() {
1010 local result=()
1111
1212 # words the user already typed (excluding the command itself)
13- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
13+ local used=()
14+ if (( COMP_CWORD > 1 )) ; then
15+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
16+ fi
1417
1518 if [[ " ${cur: 0: 1} " == " -" ]]; then
1619 # Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mygit_completions_filter() {
3841
3942_mygit_completions () {
4043 local cur=${COMP_WORDS[COMP_CWORD]}
41- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
44+ local compwords=()
45+ if (( COMP_CWORD > 0 )) ; then
46+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
47+ fi
4248 local compline=" ${compwords[*]} "
4349
50+ COMPREPLY=()
51+
4452 case " $compline " in
4553 * )
4654 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -W " $( _mygit_completions_filter " status commit" ) " -- " $cur " )
Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ _completely_completions_filter() {
1010 local result=()
1111
1212 # words the user already typed (excluding the command itself)
13- local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
13+ local used=()
14+ if (( COMP_CWORD > 1 )) ; then
15+ used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
16+ fi
1417
1518 if [[ " ${cur: 0: 1} " == " -" ]]; then
1619 # Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _completely_completions_filter() {
3841
3942_completely_completions () {
4043 local cur=${COMP_WORDS[COMP_CWORD]}
41- local compwords=(" ${COMP_WORDS[@]: 1: $COMP_CWORD -1} " )
44+ local compwords=()
45+ if (( COMP_CWORD > 0 )) ; then
46+ compwords=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
47+ fi
4248 local compline=" ${compwords[*]} "
4349
50+ COMPREPLY=()
51+
4452 case " $compline " in
4553 ' generate' * )
4654 while read -r; do COMPREPLY+=(" $REPLY " ); done < <( compgen -A directory -W " $( _completely_completions_filter " --help --force" ) " -- " $cur " )
You can’t perform that action at this time.
0 commit comments