comparison contrib/bash_completion @ 1584:b3e94785ab69

merge with crew
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Sun, 11 Dec 2005 15:38:42 -0800
parents 561b17b7d3a2
children 851bc33ff545
comparison
equal deleted inserted replaced
1583:32a4e6802864 1584:b3e94785ab69
1 shopt -s extglob 1 shopt -s extglob
2 2
3 _hg_commands() 3 _hg_commands()
4 { 4 {
5 local commands="$(hg -v help | sed -e '1,/^list of commands:/d' \ 5 local all commands result
6 -e '/^global options:/,$d' \ 6
7 -e '/^ [^ ]/!d; s/[,:]//g;')" 7 all=($(hg --debug help | sed -e '1,/^list of commands:/d' \
8 -e '/^global options:/,$d' \
9 -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;'))
10
11 commands="${all[*]##debug*}"
12 result=$(compgen -W "${commands[*]}" -- "$cur")
8 13
9 # hide debug commands from users, but complete them if 14 # hide debug commands from users, but complete them if
10 # specifically asked for 15 # there is no other possible command
11 if [[ "$cur" == de* ]]; then 16 if [ "$result" = "" ]; then
12 commands="$commands debugcheckstate debugstate debugindex" 17 local debug
13 commands="$commands debugindexdot debugwalk debugdata" 18 debug=(${all[*]##!(debug*)})
14 commands="$commands debugancestor debugconfig debugrename" 19 debug="${debug[*]/g/debug}"
20 result=$(compgen -W "$debug" -- "$cur")
15 fi 21 fi
16 COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cur") ) 22
23 COMPREPLY=(${COMPREPLY[@]:-} $result)
17 } 24 }
18 25
19 _hg_paths() 26 _hg_paths()
20 { 27 {
21 local paths="$(hg paths | sed -e 's/ = .*$//')" 28 local paths="$(hg paths | sed -e 's/ = .*$//')"
159 else 166 else
160 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" )) 167 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" ))
161 fi 168 fi
162 ;; 169 ;;
163 *) 170 *)
164 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" )) 171 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -- "$cur" ))
165 ;; 172 ;;
166 esac 173 esac
167 174
168 } 175 }
169 176