Mercurial > hg
annotate contrib/bash_completion @ 5761:07df2a5c02b2
Adjust changed test output after 0145f9afb0e7 (trailing whitespace)
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 30 Dec 2007 17:36:49 +0100 |
parents | bb417470d62a |
children | 59200a2de7bf |
rev | line source |
---|---|
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
1 # bash completion for the Mercurial distributed SCM |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
2 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
3 # Docs: |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
4 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
5 # If you source this file from your .bashrc, bash should be able to |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
6 # complete a command line that uses hg with all the available commands |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
7 # and options and sometimes even arguments. |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
8 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
9 # Mercurial allows you to define additional commands through extensions. |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
10 # Bash should be able to automatically figure out the name of these new |
3485
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
11 # commands and their options. See below for how to define _hg_opt_foo |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
12 # and _hg_cmd_foo functions to fine-tune the completion for option and |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
13 # non-option arguments, respectively. |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
14 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
15 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
16 # Notes about completion for specific commands: |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
17 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
18 # - the completion function for the email command from the patchbomb |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
19 # extension will try to call _hg_emails to get a list of e-mail |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
20 # addresses. It's up to the user to define this function. For |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
21 # example, put the addresses of the lists that you usually patchbomb |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
22 # in ~/.patchbomb-to and the addresses that you usually use to send |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
23 # the patchbombs in ~/.patchbomb-from and use something like this: |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
24 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
25 # _hg_emails() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
26 # { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
27 # if [ -r ~/.patchbomb-$1 ]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
28 # cat ~/.patchbomb-$1 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
29 # fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
30 # } |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3993
diff
changeset
|
31 # |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
32 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
33 # Writing completion functions for additional commands: |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
34 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
35 # If it exists, the function _hg_cmd_foo will be called without |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
36 # arguments to generate the completion candidates for the hg command |
3485
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
37 # "foo". If the command receives some arguments that aren't options |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
38 # even though they start with a "-", you can define a function called |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
39 # _hg_opt_foo to generate the completion candidates. If _hg_opt_foo |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
40 # doesn't return 0, regular completion for options is attempted. |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
41 # |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
42 # In addition to the regular completion variables provided by bash, |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
43 # the following variables are also set: |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
44 # - $hg - the hg program being used (e.g. /usr/bin/hg) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
45 # - $cmd - the name of the hg command being completed |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
46 # - $cmd_index - the index of $cmd in $COMP_WORDS |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
47 # - $cur - the current argument being completed |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
48 # - $prev - the argument before $cur |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
49 # - $global_args - "|"-separated list of global options that accept |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
50 # an argument (e.g. '--cwd|-R|--repository') |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
51 # - $canonical - 1 if we canonicalized $cmd before calling the function |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
52 # 0 otherwise |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3993
diff
changeset
|
53 # |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
54 |
1311
db8bebb08f8f
bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents:
1308
diff
changeset
|
55 shopt -s extglob |
db8bebb08f8f
bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents:
1308
diff
changeset
|
56 |
916 | 57 _hg_commands() |
58 { | |
1888
283d2ab1e020
Make bash_completion more robust for e.g. broken hgrc or old hg installations.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1887
diff
changeset
|
59 local commands |
283d2ab1e020
Make bash_completion more robust for e.g. broken hgrc or old hg installations.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1887
diff
changeset
|
60 commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands="" |
1887
913397c27cd8
new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1820
diff
changeset
|
61 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur")) |
916 | 62 } |
63 | |
64 _hg_paths() | |
65 { | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
66 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
|
67 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) |
916 | 68 } |
69 | |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
70 _hg_repos() |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
71 { |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
72 local i |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
73 for i in $(compgen -d -- "$cur"); do |
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
74 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
|
75 done |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
76 } |
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
77 |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
78 _hg_status() |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
79 { |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
80 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
|
81 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
|
82 } |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
83 |
916 | 84 _hg_tags() |
85 { | |
2035
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
86 local tags="$("$hg" tags -q 2>/dev/null)" |
107dc72880f8
Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2034
diff
changeset
|
87 local IFS=$'\n' |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
88 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) |
916 | 89 } |
90 | |
91 # this is "kind of" ugly... | |
92 _hg_count_non_option() | |
93 { | |
94 local i count=0 | |
95 local filters="$1" | |
96 | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
97 for ((i=1; $i<=$COMP_CWORD; i++)); do |
916 | 98 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
|
99 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
|
100 continue |
ff560ce0c635
bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1151
diff
changeset
|
101 fi |
916 | 102 count=$(($count + 1)) |
103 fi | |
104 done | |
105 | |
106 echo $(($count - 1)) | |
107 } | |
108 | |
109 _hg() | |
110 { | |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
111 local cur prev cmd cmd_index opts i |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
112 # global options that receive an argument |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
113 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
|
114 local hg="$1" |
3485
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
115 local canonical=0 |
916 | 116 |
117 COMPREPLY=() | |
118 cur="$2" | |
119 prev="$3" | |
120 | |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1263
diff
changeset
|
121 # searching for the command |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
122 # (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
|
123 # receives an argument) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
124 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
|
125 if [[ ${COMP_WORDS[i]} != -* ]]; then |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
126 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
|
127 cmd="${COMP_WORDS[i]}" |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
128 cmd_index=$i |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
129 break |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
130 fi |
916 | 131 fi |
132 done | |
133 | |
134 if [[ "$cur" == -* ]]; then | |
3485
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
135 if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
136 return |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
137 fi |
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
138 |
2034
5e7aff1b6ae1
add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1888
diff
changeset
|
139 opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null) |
916 | 140 |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
141 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
916 | 142 return |
143 fi | |
144 | |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
145 # global options |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
146 case "$prev" in |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
147 -R|--repository) |
3992
d86ab4ba5ae6
Yield entries from [paths], too, when completing -R/--repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3486
diff
changeset
|
148 _hg_paths |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
149 _hg_repos |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
150 return |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
151 ;; |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
152 --cwd) |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
153 # Stick with default bash completion |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
154 return |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
155 ;; |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
156 esac |
916 | 157 |
158 if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then | |
159 _hg_commands | |
160 return | |
161 fi | |
162 | |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
163 # try to generate completion candidates for whatever command the user typed |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
164 local help |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
165 if _hg_command_specific; then |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
166 return |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
167 fi |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
168 |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
169 # canonicalize the command name and try again |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
170 help=$("$hg" help "$cmd" 2>/dev/null) |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
171 if [ $? -ne 0 ]; then |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
172 # Probably either the command doesn't exist or it's ambiguous |
916 | 173 return |
174 fi | |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
175 cmd=${help#hg } |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
176 cmd=${cmd%%[$' \n']*} |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
177 canonical=1 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
178 _hg_command_specific |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
179 } |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
180 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
181 _hg_command_specific() |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
182 { |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
183 if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
184 "_hg_cmd_$cmd" |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
185 return 0 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
186 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
187 |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
188 if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
189 if [ $canonical = 1 ]; then |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
190 _hg_tags |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
191 return 0 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
192 elif [[ status != "$cmd"* ]]; then |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
193 _hg_tags |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
194 return 0 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
195 else |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
196 return 1 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
197 fi |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
198 fi |
916 | 199 |
200 case "$cmd" in | |
201 help) | |
202 _hg_commands | |
203 ;; | |
3481
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
204 export) |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
205 if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
206 return 0 |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
207 fi |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
208 _hg_tags |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
209 ;; |
13a9a2136dd7
bash_completion: make export fall back to tags when there's no mq patch applied
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3480
diff
changeset
|
210 manifest|update) |
916 | 211 _hg_tags |
212 ;; | |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
213 pull|push|outgoing|incoming) |
916 | 214 _hg_paths |
1587
851bc33ff545
Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents:
1556
diff
changeset
|
215 _hg_repos |
916 | 216 ;; |
217 paths) | |
218 _hg_paths | |
219 ;; | |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
220 add) |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
221 _hg_status "u" |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
222 ;; |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
223 commit) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
224 _hg_status "mar" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
225 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
226 remove) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
227 _hg_status "d" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
228 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
229 forget) |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
230 _hg_status "a" |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
231 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
232 diff) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
233 _hg_status "mar" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
234 ;; |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
235 revert) |
1639
dbfc04a55607
_hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1638
diff
changeset
|
236 _hg_status "mard" |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
237 ;; |
916 | 238 clone) |
239 local count=$(_hg_count_non_option) | |
240 if [ $count = 1 ]; then | |
241 _hg_paths | |
242 fi | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
243 _hg_repos |
916 | 244 ;; |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
245 debugindex|debugindexdot) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
246 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
247 ;; |
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
248 debugdata) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
249 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) |
1115
89f54e72581d
bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents:
1018
diff
changeset
|
250 ;; |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
251 *) |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
252 return 1 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
253 ;; |
916 | 254 esac |
255 | |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
256 return 0 |
916 | 257 } |
258 | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
259 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
|
260 || complete -o default -F _hg hg |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
261 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
262 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
263 # Completion for commands provided by extensions |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
264 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
265 # mq |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
266 _hg_ext_mq_patchlist() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
267 { |
3480
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
268 local patches |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
269 patches=$("$hg" $1 2>/dev/null) |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
270 if [ $? -eq 0 ] && [ "$patches" ]; then |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
271 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur")) |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
272 return 0 |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
273 fi |
03932425cfd8
bash_completion: don't complete export with "garbage" when mq is not around
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2695
diff
changeset
|
274 return 1 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
275 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
276 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
277 _hg_ext_mq_queues() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
278 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
279 local root=$("$hg" root 2>/dev/null) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
280 local n |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
281 for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
282 # I think we're usually not interested in the regular "patches" queue |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
283 # so just filter it. |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
284 if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
285 COMPREPLY=(${COMPREPLY[@]:-} "$n") |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
286 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
287 done |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
288 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
289 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
290 _hg_cmd_qpop() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
291 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
292 if [[ "$prev" = @(-n|--name) ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
293 _hg_ext_mq_queues |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
294 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
295 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
296 _hg_ext_mq_patchlist qapplied |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
297 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
298 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
299 _hg_cmd_qpush() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
300 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
301 if [[ "$prev" = @(-n|--name) ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
302 _hg_ext_mq_queues |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
303 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
304 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
305 _hg_ext_mq_patchlist qunapplied |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
306 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
307 |
5507
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
308 _hg_cmd_qgoto() |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
309 { |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
310 if [[ "$prev" = @(-n|--name) ]]; then |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
311 _hg_ext_mq_queues |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
312 return |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
313 fi |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
314 _hg_ext_mq_patchlist qseries |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
315 } |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
316 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
317 _hg_cmd_qdelete() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
318 { |
3482
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
319 local qcmd=qunapplied |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
320 if [[ "$prev" = @(-r|--rev) ]]; then |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
321 qcmd=qapplied |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
322 fi |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
323 _hg_ext_mq_patchlist $qcmd |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
324 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
325 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
326 _hg_cmd_qsave() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
327 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
328 if [[ "$prev" = @(-n|--name) ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
329 _hg_ext_mq_queues |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
330 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
331 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
332 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
333 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
334 _hg_cmd_strip() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
335 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
336 _hg_tags |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
337 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
338 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
339 _hg_cmd_qcommit() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
340 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
341 local root=$("$hg" root 2>/dev/null) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
342 # this is run in a sub-shell, so we can't use _hg_status |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
343 local files=$(cd "$root/.hg/patches" 2>/dev/null && |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
344 "$hg" status -nmar 2>/dev/null) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
345 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
346 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
347 |
3484
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
348 _hg_cmd_qfold() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
349 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
350 _hg_ext_mq_patchlist qunapplied |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
351 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
352 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
353 _hg_cmd_qrename() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
354 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
355 _hg_ext_mq_patchlist qseries |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
356 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
357 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
358 _hg_cmd_qheader() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
359 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
360 _hg_ext_mq_patchlist qseries |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
361 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
362 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
363 _hg_cmd_qclone() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
364 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
365 local count=$(_hg_count_non_option) |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
366 if [ $count = 1 ]; then |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
367 _hg_paths |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
368 fi |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
369 _hg_repos |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
370 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
371 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
372 _hg_ext_mq_guards() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
373 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
374 "$hg" qselect --series 2>/dev/null | sed -e 's/^.//' |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
375 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
376 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
377 _hg_cmd_qselect() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
378 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
379 local guards=$(_hg_ext_mq_guards) |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
380 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$guards' -- "$cur")) |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
381 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
382 |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
383 _hg_cmd_qguard() |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
384 { |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
385 local prefix='' |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
386 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
387 if [[ "$cur" == +* ]]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
388 prefix=+ |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
389 elif [[ "$cur" == -* ]]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
390 prefix=- |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
391 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
392 local ncur=${cur#[-+]} |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
393 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
394 if ! [ "$prefix" ]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
395 _hg_ext_mq_patchlist qseries |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
396 return |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
397 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
398 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
399 local guards=$(_hg_ext_mq_guards) |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
400 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur")) |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
401 } |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
402 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
403 _hg_opt_qguard() |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
404 { |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
405 local i |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
406 for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
407 if [[ ${COMP_WORDS[i]} != -* ]]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
408 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
409 _hg_cmd_qguard |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
410 return 0 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
411 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
412 elif [ "${COMP_WORDS[i]}" = -- ]; then |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
413 _hg_cmd_qguard |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
414 return 0 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
415 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
416 done |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
417 return 1 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
418 } |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
419 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
420 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
421 # hbisect |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
422 _hg_cmd_bisect() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
423 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
424 local i subcmd |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
425 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
426 # find the sub-command |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
427 for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
428 if [[ ${COMP_WORDS[i]} != -* ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
429 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
430 subcmd="${COMP_WORDS[i]}" |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
431 break |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
432 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
433 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
434 done |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
435 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
436 if [ -z "$subcmd" ] || [ $COMP_CWORD -eq $i ] || [ "$subcmd" = help ]; then |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3993
diff
changeset
|
437 COMPREPLY=(${COMPREPLY[@]:-} |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
438 $(compgen -W 'bad good help init next reset' -- "$cur")) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
439 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
440 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
441 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
442 case "$subcmd" in |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
443 good|bad) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
444 _hg_tags |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
445 ;; |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
446 esac |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
447 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
448 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
449 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
450 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
451 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
452 # patchbomb |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
453 _hg_cmd_email() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
454 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
455 case "$prev" in |
3483
34cc82c6c7c2
bash_completion: email --bcc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3482
diff
changeset
|
456 -c|--cc|-t|--to|-f|--from|--bcc) |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3993
diff
changeset
|
457 # we need an e-mail address. let the user provide a function |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
458 # to get them |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
459 if [ "$(type -t _hg_emails)" = function ]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
460 local arg=to |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
461 if [[ "$prev" == @(-f|--from) ]]; then |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
462 arg=from |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
463 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
464 local addresses=$(_hg_emails $arg) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
465 COMPREPLY=(${COMPREPLY[@]:-} |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
466 $(compgen -W '$addresses' -- "$cur")) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
467 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
468 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
469 ;; |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
470 -m|--mbox) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
471 # fallback to standard filename completion |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
472 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
473 ;; |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
474 -s|--subject) |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
475 # free form string |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
476 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
477 ;; |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
478 esac |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
479 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
480 _hg_tags |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
481 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
482 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
483 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
484 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
485 # gpg |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
486 _hg_cmd_sign() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
487 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
488 _hg_tags |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
489 } |
3993
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
490 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
491 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
492 # transplant |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
493 _hg_cmd_transplant() |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
494 { |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
495 case "$prev" in |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
496 -s|--source) |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
497 _hg_paths |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
498 _hg_repos |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
499 return |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
500 ;; |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
501 --filter) |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
502 # standard filename completion |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
503 return |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
504 ;; |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
505 esac |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
506 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
507 # all other transplant options values and command parameters are revisions |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
508 _hg_tags |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
509 return |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
510 } |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
511 |