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