comparison contrib/bash_completion @ 1638:1c75487badd6

bash_completion: small updates and fixes - $result in _hg_commands is not an array - use "hg status ." - update "hg cat" completion - let bash itself generate the default completion
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Thu, 26 Jan 2006 14:52:26 +0100
parents 851bc33ff545
children dbfc04a55607
comparison
equal deleted inserted replaced
1637:3b1b44b917f4 1638:1c75487badd6
7 all=($(hg --debug help | sed -e '1,/^list of commands:/d' \ 7 all=($(hg --debug help | sed -e '1,/^list of commands:/d' \
8 -e '/^global options:/,$d' \ 8 -e '/^global options:/,$d' \
9 -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;')) 9 -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;'))
10 10
11 commands="${all[*]##debug*}" 11 commands="${all[*]##debug*}"
12 result=$(compgen -W "${commands[*]}" -- "$cur") 12 result=$(compgen -W "$commands" -- "$cur")
13 13
14 # hide debug commands from users, but complete them if 14 # hide debug commands from users, but complete them if
15 # there is no other possible command 15 # there is no other possible command
16 if [ "$result" = "" ]; then 16 if [ "$result" = "" ]; then
17 local debug 17 local debug
37 done 37 done
38 } 38 }
39 39
40 _hg_status() 40 _hg_status()
41 { 41 {
42 local files="$( hg status -$1 | cut -b 3- )" 42 local files="$( hg status -$1 . | cut -b 3- )"
43 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$files" -- "$cur" )) 43 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$files" -- "$cur" ))
44 } 44 }
45 45
46 _hg_tags() 46 _hg_tags()
47 { 47 {
165 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.i" -- "$cur" )) 165 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.i" -- "$cur" ))
166 ;; 166 ;;
167 debugdata) 167 debugdata)
168 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.d" -- "$cur" )) 168 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.d" -- "$cur" ))
169 ;; 169 ;;
170 cat)
171 local count=$(_hg_count_non_option '-o|--output')
172 if [ $count = 2 ]; then
173 _hg_tags
174 else
175 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" ))
176 fi
177 ;;
178 *)
179 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" ))
180 ;;
181 esac 170 esac
182 171
183 } 172 }
184 173
185 complete -o bashdefault -o default -F _hg hg 2> /dev/null \ 174 complete -o bashdefault -o default -F _hg hg 2> /dev/null \