File tree Expand file tree Collapse file tree 14 files changed +214
-26
lines changed Expand file tree Collapse file tree 14 files changed +214
-26
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,9 @@ action :schema do
2424 end
2525end
2626
27+ help 'Run preconfigured shfmt on any script'
28+ usage 'shfmt SCRIPT'
29+ action :shfmt do |args|
30+ system "shfmt -d -i 2 -ci #{args['SCRIPT']}"
31+ say $?.success? ? 'g`PASS`' : 'r`FAIL`'
32+ end
Original file line number Diff line number Diff line change 99 local cur=${COMP_WORDS[COMP_CWORD]}
1010 local result=()
1111
12+ # words the user already typed (excluding the command itself)
13+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
14+
1215 if [[ " ${cur: 0: 1} " == " -" ]]; then
16+ # Completing an option: offer everything (including options)
1317 echo " $words "
1418
1519 else
20+ # Completing a non-option: offer only non-options,
21+ # and don't re-offer ones already used earlier in the line.
1622 for word in $words ; do
17- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
23+ [[ " ${word: 0: 1} " == " -" ]] && continue
24+
25+ local seen=0
26+ for u in " ${used[@]} " ; do
27+ if [[ " $u " == " $word " ]]; then
28+ seen=1
29+ break
30+ fi
31+ done
32+ (( ! seen)) && result+=(" $word " )
1833 done
1934
2035 echo " ${result[*]} "
21-
2236 fi
2337}
2438
Original file line number Diff line number Diff line change @@ -9,16 +9,30 @@ _mygit_completions_filter() {
99 local cur=${COMP_WORDS[COMP_CWORD]}
1010 local result=()
1111
12+ # words the user already typed (excluding the command itself)
13+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
14+
1215 if [[ " ${cur: 0: 1} " == " -" ]]; then
16+ # Completing an option: offer everything (including options)
1317 echo " $words "
1418
1519 else
20+ # Completing a non-option: offer only non-options,
21+ # and don't re-offer ones already used earlier in the line.
1622 for word in $words ; do
17- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
23+ [[ " ${word: 0: 1} " == " -" ]] && continue
24+
25+ local seen=0
26+ for u in " ${used[@]} " ; do
27+ if [[ " $u " == " $word " ]]; then
28+ seen=1
29+ break
30+ fi
31+ done
32+ (( ! seen)) && result+=(" $word " )
1833 done
1934
2035 echo " ${result[*]} "
21-
2236 fi
2337}
2438
Original file line number Diff line number Diff line change @@ -9,16 +9,30 @@ _mycomps_filter() {
99 local cur=${COMP_WORDS[COMP_CWORD]}
1010 local result=()
1111
12+ # words the user already typed (excluding the command itself)
13+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
14+
1215 if [[ " ${cur: 0: 1} " == " -" ]]; then
16+ # Completing an option: offer everything (including options)
1317 echo " $words "
1418
1519 else
20+ # Completing a non-option: offer only non-options,
21+ # and don't re-offer ones already used earlier in the line.
1622 for word in $words ; do
17- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
23+ [[ " ${word: 0: 1} " == " -" ]] && continue
24+
25+ local seen=0
26+ for u in " ${used[@]} " ; do
27+ if [[ " $u " == " $word " ]]; then
28+ seen=1
29+ break
30+ fi
31+ done
32+ (( ! seen)) && result+=(" $word " )
1833 done
1934
2035 echo " ${result[*]} "
21-
2236 fi
2337}
2438
Original file line number Diff line number Diff line change @@ -10,16 +10,30 @@ give_comps() {
1010 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1111 echo $' local result=()'
1212 echo $' '
13+ echo $' # words the user already typed (excluding the command itself)'
14+ echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
15+ echo $' '
1316 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
17+ echo $' # Completing an option: offer everything (including options)'
1418 echo $' echo "$words"'
1519 echo $' '
1620 echo $' else'
21+ echo $' # Completing a non-option: offer only non-options,'
22+ echo $' # and don\' t re-offer ones already used earlier in the line.'
1723 echo $' for word in $words; do'
18- echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
24+ echo $' [[ "${word:0:1}" == "-" ]] && continue'
25+ echo $' '
26+ echo $' local seen=0'
27+ echo $' for u in "${used[@]}"; do'
28+ echo $' if [[ "$u" == "$word" ]]; then'
29+ echo $' seen=1'
30+ echo $' break'
31+ echo $' fi'
32+ echo $' done'
33+ echo $' ((!seen)) && result+=("$word")'
1934 echo $' done'
2035 echo $' '
2136 echo $' echo "${result[*]}"'
22- echo $' '
2337 echo $' fi'
2438 echo $' }'
2539 echo $' '
Original file line number Diff line number Diff line change @@ -17,16 +17,30 @@ _mygit_completions_filter() {
1717 local cur=${COMP_WORDS[COMP_CWORD]}
1818 local result=()
1919
20+ # words the user already typed (excluding the command itself)
21+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
22+
2023 if [[ " ${cur: 0: 1} " == " -" ]]; then
24+ # Completing an option: offer everything (including options)
2125 echo " $words "
2226
2327 else
28+ # Completing a non-option: offer only non-options,
29+ # and don't re-offer ones already used earlier in the line.
2430 for word in $words ; do
25- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
31+ [[ " ${word: 0: 1} " == " -" ]] && continue
32+
33+ local seen=0
34+ for u in " ${used[@]} " ; do
35+ if [[ " $u " == " $word " ]]; then
36+ seen=1
37+ break
38+ fi
39+ done
40+ (( ! seen)) && result+=(" $word " )
2641 done
2742
2843 echo " ${result[*]} "
29-
3044 fi
3145}
3246
Original file line number Diff line number Diff line change @@ -17,16 +17,30 @@ _mygit_completions_filter() {
1717 local cur=${COMP_WORDS[COMP_CWORD]}
1818 local result=()
1919
20+ # words the user already typed (excluding the command itself)
21+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
22+
2023 if [[ " ${cur: 0: 1} " == " -" ]]; then
24+ # Completing an option: offer everything (including options)
2125 echo " $words "
2226
2327 else
28+ # Completing a non-option: offer only non-options,
29+ # and don't re-offer ones already used earlier in the line.
2430 for word in $words ; do
25- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
31+ [[ " ${word: 0: 1} " == " -" ]] && continue
32+
33+ local seen=0
34+ for u in " ${used[@]} " ; do
35+ if [[ " $u " == " $word " ]]; then
36+ seen=1
37+ break
38+ fi
39+ done
40+ (( ! seen)) && result+=(" $word " )
2641 done
2742
2843 echo " ${result[*]} "
29-
3044 fi
3145}
3246
Original file line number Diff line number Diff line change @@ -17,16 +17,30 @@ _mygit_completions_filter() {
1717 local cur=${COMP_WORDS[COMP_CWORD]}
1818 local result=()
1919
20+ # words the user already typed (excluding the command itself)
21+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
22+
2023 if [[ " ${cur: 0: 1} " == " -" ]]; then
24+ # Completing an option: offer everything (including options)
2125 echo " $words "
2226
2327 else
28+ # Completing a non-option: offer only non-options,
29+ # and don't re-offer ones already used earlier in the line.
2430 for word in $words ; do
25- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
31+ [[ " ${word: 0: 1} " == " -" ]] && continue
32+
33+ local seen=0
34+ for u in " ${used[@]} " ; do
35+ if [[ " $u " == " $word " ]]; then
36+ seen=1
37+ break
38+ fi
39+ done
40+ (( ! seen)) && result+=(" $word " )
2641 done
2742
2843 echo " ${result[*]} "
29-
3044 fi
3145}
3246
Original file line number Diff line number Diff line change @@ -10,16 +10,30 @@ send_completions() {
1010 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1111 echo $' local result=()'
1212 echo $' '
13+ echo $' # words the user already typed (excluding the command itself)'
14+ echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
15+ echo $' '
1316 echo $' if [[ "${cur:0:1}" == "-" ]]; then'
17+ echo $' # Completing an option: offer everything (including options)'
1418 echo $' echo "$words"'
1519 echo $' '
1620 echo $' else'
21+ echo $' # Completing a non-option: offer only non-options,'
22+ echo $' # and don\' t re-offer ones already used earlier in the line.'
1723 echo $' for word in $words; do'
18- echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
24+ echo $' [[ "${word:0:1}" == "-" ]] && continue'
25+ echo $' '
26+ echo $' local seen=0'
27+ echo $' for u in "${used[@]}"; do'
28+ echo $' if [[ "$u" == "$word" ]]; then'
29+ echo $' seen=1'
30+ echo $' break'
31+ echo $' fi'
32+ echo $' done'
33+ echo $' ((!seen)) && result+=("$word")'
1934 echo $' done'
2035 echo $' '
2136 echo $' echo "${result[*]}"'
22- echo $' '
2337 echo $' fi'
2438 echo $' }'
2539 echo $' '
Original file line number Diff line number Diff line change @@ -9,16 +9,30 @@ _completely_completions_filter() {
99 local cur=${COMP_WORDS[COMP_CWORD]}
1010 local result=()
1111
12+ # words the user already typed (excluding the command itself)
13+ local used=(" ${COMP_WORDS[@]: 1: $((COMP_CWORD - 1))} " )
14+
1215 if [[ " ${cur: 0: 1} " == " -" ]]; then
16+ # Completing an option: offer everything (including options)
1317 echo " $words "
1418
1519 else
20+ # Completing a non-option: offer only non-options,
21+ # and don't re-offer ones already used earlier in the line.
1622 for word in $words ; do
17- [[ " ${word: 0: 1} " != " -" ]] && result+=(" $word " )
23+ [[ " ${word: 0: 1} " == " -" ]] && continue
24+
25+ local seen=0
26+ for u in " ${used[@]} " ; do
27+ if [[ " $u " == " $word " ]]; then
28+ seen=1
29+ break
30+ fi
31+ done
32+ (( ! seen)) && result+=(" $word " )
1833 done
1934
2035 echo " ${result[*]} "
21-
2236 fi
2337}
2438
You can’t perform that action at this time.
0 commit comments