Mercurial > hg-stable
annotate contrib/bash_completion @ 1820:7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Use substr instead of sub.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Wed, 01 Mar 2006 14:52:28 +0100 |
parents | 2af98c4b2587 |
children | 913397c27cd8 |
rev | line source |
---|---|
1311
db8bebb08f8f
bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents:
1308
diff
changeset
|
1 shopt -s extglob |
db8bebb08f8f
bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents:
1308
diff
changeset
|
2 |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
3 _hg_command_list() |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
4 { |
1683
063e04831a09
Use user specified path to hg in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1643
diff
changeset
|
5 "$hg" --debug help 2>/dev/null | \ |
1805
2af98c4b2587
Fix bash_completion on Solaris
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1684
diff
changeset
|
6 awk -F', ' '/^list of commands:/ {commands=1} |
1820
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
7 commands==1 && /^ [^ ]/ { |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
8 line = substr($0, 2) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
9 colon = index(line, ":") |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
10 if (colon > 0) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
11 line = substr(line, 1, colon-1) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
12 n = split(line, aliases) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
13 command = aliases[1] |
1805
2af98c4b2587
Fix bash_completion on Solaris
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1684
diff
changeset
|
14 if (index(command, "debug") == 1) { |
1820
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
15 for (i=1; i<=n; i++) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
16 debug[j++] = aliases[i] |
1805
2af98c4b2587
Fix bash_completion on Solaris
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1684
diff
changeset
|
17 next |
2af98c4b2587
Fix bash_completion on Solaris
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1684
diff
changeset
|
18 } |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
19 print command |
1820
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
20 for (i=2; i<=n; i++) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
21 if (index(command, aliases[i]) != 1) |
7e10518b2b9e
Really fix bash_completion on Solaris. Maybe. Hopefully.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1805
diff
changeset
|
22 print aliases[i] |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
23 } |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
24 /^global options:/ {exit 0} |
1805
2af98c4b2587
Fix bash_completion on Solaris
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1684
diff
changeset
|
25 END {for (i in debug) print debug[i]}' |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
26 } |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
27 |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
28 _hg_option_list() |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
29 { |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
30 "$hg" -v help $1 2>/dev/null | \ |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
31 awk '/^ *-/ { |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
32 for (i = 1; i <= NF; i ++) { |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
33 if (index($i, "-") != 1) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
34 break; |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
35 print $i; |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
36 } |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
37 }' |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
38 } |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
39 |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
40 |
916 | 41 _hg_commands() |
42 { | |
1555
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
43 local all commands result |
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
44 |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
45 all=$(_hg_command_list) |
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
46 commands=${all%%$'\n'debug*} |
1642
b8d792057e5b
bash_completion: always use single quotes with compgen -W
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1641
diff
changeset
|
47 result=$(compgen -W '$commands' -- "$cur") |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1263
diff
changeset
|
48 |
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1263
diff
changeset
|
49 # hide debug commands from users, but complete them if |
1555
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
50 # there is no other possible command |
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
51 if [ "$result" = "" ]; then |
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
52 local debug |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
53 debug=debug${all#*$'\n'debug} |
1642
b8d792057e5b
bash_completion: always use single quotes with compgen -W
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1641
diff
changeset
|
54 result=$(compgen -W '$debug' -- "$cur") |
916 | 55 fi |
1555
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
56 |
01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1339
diff
changeset
|
57 COMPREPLY=(${COMPREPLY[@]:-} $result) |
916 | 58 } |
59 | |
60 _hg_paths() | |
61 { | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
62 local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')" |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
63 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) |
916 | 64 } |
65 | |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
66 _hg_repos() |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
67 { |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
68 local i |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
69 for i in $(compgen -d -- "$cur"); do |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
70 test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i") |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
71 done |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
72 } |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
73 |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
74 _hg_status() |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
75 { |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
76 local files="$("$hg" status -n$1 . 2>/dev/null)" |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
77 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
78 } |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
79 |
916 | 80 _hg_tags() |
81 { | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
82 local tags="$("$hg" tags 2>/dev/null | |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
83 sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
84 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) |
916 | 85 } |
86 | |
87 # this is "kind of" ugly... | |
88 _hg_count_non_option() | |
89 { | |
90 local i count=0 | |
91 local filters="$1" | |
92 | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
93 for ((i=1; $i<=$COMP_CWORD; i++)); do |
916 | 94 if [[ "${COMP_WORDS[i]}" != -* ]]; then |
1152
ff560ce0c635
bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1151
diff
changeset
|
95 if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then |
ff560ce0c635
bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1151
diff
changeset
|
96 continue |
ff560ce0c635
bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1151
diff
changeset
|
97 fi |
916 | 98 count=$(($count + 1)) |
99 fi | |
100 done | |
101 | |
102 echo $(($count - 1)) | |
103 } | |
104 | |
105 _hg() | |
106 { | |
107 local cur prev cmd opts i | |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
108 # global options that receive an argument |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
109 local global_args='--cwd|-R|--repository' |
1683
063e04831a09
Use user specified path to hg in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1643
diff
changeset
|
110 local hg="$1" |
916 | 111 |
112 COMPREPLY=() | |
113 cur="$2" | |
114 prev="$3" | |
115 | |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1263
diff
changeset
|
116 # searching for the command |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
117 # (first non-option argument that doesn't follow a global option that |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
118 # receives an argument) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
119 for ((i=1; $i<=$COMP_CWORD; i++)); do |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
120 if [[ ${COMP_WORDS[i]} != -* ]]; then |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
121 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
122 cmd="${COMP_WORDS[i]}" |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
123 break |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
124 fi |
916 | 125 fi |
126 done | |
127 | |
128 if [[ "$cur" == -* ]]; then | |
1641
1ef060ae7966
bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1639
diff
changeset
|
129 opts=$(_hg_option_list $cmd) |
916 | 130 |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
131 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
916 | 132 return |
133 fi | |
134 | |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
135 # global options |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
136 case "$prev" in |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
137 -R|--repository) |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
138 _hg_repos |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
139 return |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
140 ;; |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
141 --cwd) |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
142 # Stick with default bash completion |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
143 return |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
144 ;; |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
145 esac |
916 | 146 |
147 if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then | |
148 _hg_commands | |
149 return | |
150 fi | |
151 | |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
152 # canonicalize command name |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
153 cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q') |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
154 |
916 | 155 if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then |
156 _hg_tags | |
157 return | |
158 fi | |
159 | |
160 case "$cmd" in | |
161 help) | |
162 _hg_commands | |
163 ;; | |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
164 export|manifest|update) |
916 | 165 _hg_tags |
166 ;; | |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
167 pull|push|outgoing|incoming) |
916 | 168 _hg_paths |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
169 _hg_repos |
916 | 170 ;; |
171 paths) | |
172 _hg_paths | |
173 ;; | |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
174 add) |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
175 _hg_status "u" |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
176 ;; |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
177 commit) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
178 _hg_status "mar" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
179 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
180 remove) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
181 _hg_status "d" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
182 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
183 forget) |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
184 _hg_status "a" |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
185 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
186 diff) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
187 _hg_status "mar" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
188 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
189 revert) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
190 _hg_status "mard" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
191 ;; |
916 | 192 clone) |
193 local count=$(_hg_count_non_option) | |
194 if [ $count = 1 ]; then | |
195 _hg_paths | |
196 fi | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
197 _hg_repos |
916 | 198 ;; |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
199 debugindex|debugindexdot) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
200 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
201 ;; |
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
202 debugdata) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
203 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
204 ;; |
916 | 205 esac |
206 | |
207 } | |
208 | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
209 complete -o bashdefault -o default -F _hg hg 2>/dev/null \ |
1153
fa9ae7df88a9
bash_completion: try to use bash3 features if they're available
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1152
diff
changeset
|
210 || complete -o default -F _hg hg |