annotate contrib/bash_completion @ 18789:fff3a8114510

bash_completion: nuke a duplicated function
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 21 Mar 2013 09:13:16 -0700
parents 83a99f10c45c
children 1e28a7f58f33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18769
83a99f10c45c bash_completion: tell an editor what type of file this is
Bryan O'Sullivan <bryano@fb.com>
parents: 18768
diff changeset
1 # bash completion for the Mercurial distributed SCM -*- sh -*-
2041
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
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
57 _hg_cmd()
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
58 {
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
59 HGPLAIN=1 "$hg" "$@" 2>/dev/null
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
60 }
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
61
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
62 _hg_commands()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
63 {
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
64 local commands
14374
51f444e85734 bash_completion: enable alias auto-complete
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 14332
diff changeset
65 commands="$(HGPLAINEXCEPT=alias _hg_cmd debugcomplete "$cur")" || commands=""
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1820
diff changeset
66 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
67 }
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
68
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
69 _hg_paths()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
70 {
14332
a2f0f61a6988 bash_completion: Use "hg paths -q" instead of piping through sed
Thomas Arendsen Hein <thomas@intevation.de>
parents: 13509
diff changeset
71 local paths="$(_hg_cmd paths -q)"
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
72 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
73 }
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
74
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
75 _hg_repos()
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 local i
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
78 for i in $(compgen -d -- "$cur"); do
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
79 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
80 done
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
81 }
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
82
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
83 _hg_status()
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
84 {
18767
69e4787b6867 bash_completion: match more narrowly
Bryan O'Sullivan <bryano@fb.com>
parents: 17463
diff changeset
85 local files="$(_hg_cmd status -n$1 "glob:$cur**")"
6232
59200a2de7bf Fixed bash completion for filenames containing spaces.
Jonas Diemer <diemer@gmx.de>
parents: 5507
diff changeset
86 local IFS=$'\n'
15969
80f3ae36f908 bash_completion: added -o filename option to _hg_status (issue3101)
Jesus Espino Garcia <jesus.espino@kaleidos.net>
parents: 14374
diff changeset
87 compopt -o filenames 2>/dev/null
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
88 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
89 }
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
90
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
91 _hg_tags()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
92 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
93 local tags="$(_hg_cmd tags -q)"
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
94 local IFS=$'\n'
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
95 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
96 }
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
97
8719
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
98 _hg_branches()
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
99 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
100 local branches="$(_hg_cmd branches -q)"
8719
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
101 local IFS=$'\n'
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
102 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
103 }
b5e9ed63913b Support branch names in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 8718
diff changeset
104
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
105 _hg_bookmarks()
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
106 {
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
107 local bookmarks="$(_hg_cmd bookmarks -q)"
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
108 local IFS=$'\n'
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
109 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur"))
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
110 }
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
111
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
112 _hg_labels()
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
113 {
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
114 _hg_tags
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
115 _hg_branches
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
116 _hg_bookmarks
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
117 }
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
118
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
119 # this is "kind of" ugly...
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
120 _hg_count_non_option()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
121 {
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
122 local i count=0
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
123 local filters="$1"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
124
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
125 for ((i=1; $i<=$COMP_CWORD; i++)); do
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
126 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
127 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
128 continue
ff560ce0c635 bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1151
diff changeset
129 fi
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
130 count=$(($count + 1))
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
131 fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
132 done
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
133
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
134 echo $(($count - 1))
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
135 }
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
136
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
137 _hg()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
138 {
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
139 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
140 # global options that receive an argument
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
141 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
142 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
143 local canonical=0
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
144
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
145 COMPREPLY=()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
146 cur="$2"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
147 prev="$3"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
148
1308
2073e5a71008 Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1263
diff changeset
149 # searching for the command
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
150 # (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
151 # receives an argument)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
152 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
153 if [[ ${COMP_WORDS[i]} != -* ]]; then
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
154 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
155 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
156 cmd_index=$i
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
157 break
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
158 fi
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
159 fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
160 done
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
161
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
162 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
163 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
164 return
26285469db9b bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3484
diff changeset
165 fi
26285469db9b bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3484
diff changeset
166
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
167 opts=$(_hg_cmd debugcomplete --options "$cmd")
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
168
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
169 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
170 return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
171 fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
172
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
173 # global options
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
174 case "$prev" in
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
175 -R|--repository)
3992
d86ab4ba5ae6 Yield entries from [paths], too, when completing -R/--repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3486
diff changeset
176 _hg_paths
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
177 _hg_repos
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
178 return
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
179 ;;
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
180 --cwd)
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
181 # Stick with default bash completion
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
182 return
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
183 ;;
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
184 esac
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
185
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
186 if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
187 _hg_commands
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
188 return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
189 fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
190
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
191 # 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
192 local help
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
193 if _hg_command_specific; then
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
194 return
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
195 fi
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
196
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
197 # canonicalize the command name and try again
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
198 help=$(_hg_cmd help "$cmd")
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
199 if [ $? -ne 0 ]; then
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
200 # Probably either the command doesn't exist or it's ambiguous
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
201 return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
202 fi
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
203 cmd=${help#hg }
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
204 cmd=${cmd%%[$' \n']*}
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
205 canonical=1
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
206 _hg_command_specific
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
207 }
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
208
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
209 _hg_command_specific()
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
210 {
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
211 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
212 "_hg_cmd_$cmd"
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
213 return 0
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
214 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
215
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
216 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
217 if [ $canonical = 1 ]; then
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
218 _hg_labels
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
219 return 0
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
220 elif [[ status != "$cmd"* ]]; then
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
221 _hg_labels
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
222 return 0
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
223 else
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
224 return 1
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
225 fi
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
226 fi
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
227
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
228 case "$cmd" in
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
229 help)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
230 _hg_commands
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
231 ;;
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
232 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
233 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
234 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
235 fi
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
236 _hg_labels
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
237 ;;
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
238 manifest|update)
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
239 _hg_labels
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
240 ;;
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
241 pull|push|outgoing|incoming)
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
242 _hg_paths
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
243 _hg_repos
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
244 ;;
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
245 paths)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
246 _hg_paths
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
247 ;;
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
248 add)
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
249 _hg_status "u"
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
250 ;;
8718
3463b28681ee Support merge in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 6232
diff changeset
251 merge)
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
252 _hg_labels
8718
3463b28681ee Support merge in contrib/bash_completion
Steve Losh <steve@stevelosh.com>
parents: 6232
diff changeset
253 ;;
13243
159651b3c9ec bash_completion: support record command
Patrick Mezard <pmezard@gmail.com>
parents: 11968
diff changeset
254 commit|record)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
255 _hg_status "mar"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
256 ;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
257 remove)
18768
e3e601969ba1 bash_completion: allow remove to complete normal files
Bryan O'Sullivan <bryano@fb.com>
parents: 18767
diff changeset
258 _hg_status "mcd"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
259 ;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
260 forget)
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
261 _hg_status "a"
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
262 ;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
263 diff)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
264 _hg_status "mar"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
265 ;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
266 revert)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
267 _hg_status "mard"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
268 ;;
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
269 clone)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
270 local count=$(_hg_count_non_option)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
271 if [ $count = 1 ]; then
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
272 _hg_paths
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
273 fi
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
274 _hg_repos
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
275 ;;
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
276 debugindex|debugindexdot)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
277 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
278 ;;
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
279 debugdata)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
280 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
281 ;;
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
282 *)
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
283 return 1
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
284 ;;
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
285 esac
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
286
2039
0c438fd25e6e bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2035
diff changeset
287 return 0
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
288 }
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
289
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
290 complete -o bashdefault -o default -F _hg hg \
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
291 || 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
292
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
293
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
294 # 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
295
9460
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
296 # bookmarks
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
297 _hg_cmd_bookmarks()
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
298 {
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
299 if [[ "$prev" = @(-d|--delete|-m|--rename) ]]; then
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
300 _hg_bookmarks
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
301 return
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
302 fi
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
303 }
552c5a5a3502 contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents: 8719
diff changeset
304
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
305 # mq
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
306 _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
307 {
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
308 local patches
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
309 patches=$(_hg_cmd $1)
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
310 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
311 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
312 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
313 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
314 return 1
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
315 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
316
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
317 _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
318 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
319 local root=$(_hg_cmd root)
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
320 local n
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
321 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
322 # 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
323 # 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
324 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
325 COMPREPLY=(${COMPREPLY[@]:-} "$n")
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
326 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
327 done
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
328 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
329
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
330 _hg_cmd_qpop()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
331 {
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
332 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
333 _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
334 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
335 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
336 _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
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_qpush()
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 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
342 _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
343 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
344 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
345 _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
346 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
347
5507
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
348 _hg_cmd_qgoto()
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
349 {
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
350 if [[ "$prev" = @(-n|--name) ]]; then
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
351 _hg_ext_mq_queues
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
352 return
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
353 fi
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
354 _hg_ext_mq_patchlist qseries
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
355 }
bb417470d62a Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 5081
diff changeset
356
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
357 _hg_cmd_qdelete()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
358 {
3482
e762c0e95eac bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3481
diff changeset
359 local qcmd=qunapplied
e762c0e95eac bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3481
diff changeset
360 if [[ "$prev" = @(-r|--rev) ]]; then
e762c0e95eac bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3481
diff changeset
361 qcmd=qapplied
e762c0e95eac bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3481
diff changeset
362 fi
e762c0e95eac bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3481
diff changeset
363 _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
364 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
365
9840
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
366 _hg_cmd_qfinish()
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
367 {
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
368 if [[ "$prev" = @(-a|--applied) ]]; then
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
369 return
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
370 fi
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
371 _hg_ext_mq_patchlist qapplied
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
372 }
18d5935c0c62 Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents: 9602
diff changeset
373
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
374 _hg_cmd_qsave()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
375 {
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
376 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
377 _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
378 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
379 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
380 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
381
17463
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
382 _hg_cmd_rebase() {
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
383 if [[ "$prev" = @(-s|--source|-d|--dest|-b|--base|-r|--rev) ]]; then
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
384 _hg_labels
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
385 return
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
386 fi
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
387 }
e49771e2d071 bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents: 15969
diff changeset
388
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
389 _hg_cmd_strip()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
390 {
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
391 _hg_labels
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
392 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
393
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
394 _hg_cmd_qcommit()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
395 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
396 local root=$(_hg_cmd root)
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
397 # this is run in a sub-shell, so we can't use _hg_status
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
398 local files=$(cd "$root/.hg/patches" && _hg_cmd status -nmar)
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
399 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
400 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
401
3484
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
402 _hg_cmd_qfold()
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
403 {
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
404 _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
405 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
406
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
407 _hg_cmd_qrename()
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
408 {
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
409 _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
410 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
411
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
412 _hg_cmd_qheader()
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
413 {
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
414 _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
415 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
416
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
417 _hg_cmd_qclone()
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
418 {
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
419 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
420 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
421 _hg_paths
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
422 fi
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
423 _hg_repos
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
424 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
425
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
426 _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
427 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
428 _hg_cmd qselect --series | sed -e 's/^.//'
3484
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
429 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
430
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
431 _hg_cmd_qselect()
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
432 {
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
433 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
434 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
435 }
a8823e6824fc bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3483
diff changeset
436
3486
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
437 _hg_cmd_qguard()
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
438 {
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
439 local prefix=''
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
440
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
441 if [[ "$cur" == +* ]]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
442 prefix=+
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
443 elif [[ "$cur" == -* ]]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
444 prefix=-
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
445 fi
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
446 local ncur=${cur#[-+]}
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
447
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
448 if ! [ "$prefix" ]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
449 _hg_ext_mq_patchlist qseries
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
450 return
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
451 fi
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
452
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
453 local guards=$(_hg_ext_mq_guards)
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
454 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur"))
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
455 }
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
456
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
457 _hg_opt_qguard()
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
458 {
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
459 local i
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
460 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
461 if [[ ${COMP_WORDS[i]} != -* ]]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
462 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
463 _hg_cmd_qguard
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
464 return 0
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
465 fi
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
466 elif [ "${COMP_WORDS[i]}" = -- ]; then
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
467 _hg_cmd_qguard
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
468 return 0
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
469 fi
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
470 done
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
471 return 1
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
472 }
f699d4eb25d9 bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3485
diff changeset
473
11768
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
474 _hg_cmd_qqueue()
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
475 {
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
476 local q
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
477 local queues
11968
66521d25c2a6 mq/qqueue: update bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11768
diff changeset
478 local opts="--list --create --rename --delete --purge"
11768
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
479
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
480 queues=$( _hg_cmd qqueue --quiet )
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
481
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
482 COMPREPLY=( $( compgen -W "${opts} ${queues}" "${cur}" ) )
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
483 }
dc5ce9c95d00 mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents: 11646
diff changeset
484
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
485
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
486 # hbisect
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
487 _hg_cmd_bisect()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
488 {
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
489 local i subcmd
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
490
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
491 # 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
492 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
493 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
494 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
495 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
496 break
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
497 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
498 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
499 done
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
500
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
501 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
502 COMPREPLY=(${COMPREPLY[@]:-}
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
503 $(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
504 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
505 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
506
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
507 case "$subcmd" in
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
508 good|bad)
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
509 _hg_labels
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
510 ;;
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
511 esac
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
512
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
513 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
514 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
515
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
516
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
517 # patchbomb
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
518 _hg_cmd_email()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
519 {
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
520 case "$prev" in
3483
34cc82c6c7c2 bash_completion: email --bcc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3482
diff changeset
521 -c|--cc|-t|--to|-f|--from|--bcc)
5081
ea7b982b6c08 Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3993
diff changeset
522 # 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
523 # to get them
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
524 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
525 local arg=to
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
526 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
527 arg=from
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
528 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
529 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
530 COMPREPLY=(${COMPREPLY[@]:-}
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
531 $(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
532 fi
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
533 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
534 ;;
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
535 -m|--mbox)
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
536 # 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
537 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
538 ;;
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
539 -s|--subject)
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
540 # free form string
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
541 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
542 ;;
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
543 esac
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
544
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
545 _hg_labels
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
546 return
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
547 }
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
548
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
549
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
550 # gpg
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
551 _hg_cmd_sign()
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
552 {
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
553 _hg_labels
2041
077a2da7f1de bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2039
diff changeset
554 }
3993
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
555
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
556
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
557 # transplant
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
558 _hg_cmd_transplant()
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
559 {
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
560 case "$prev" in
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
561 -s|--source)
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
562 _hg_paths
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
563 _hg_repos
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
564 return
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
565 ;;
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
566 --filter)
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
567 # standard filename completion
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
568 return
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
569 ;;
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
570 esac
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
571
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
572 # all other transplant options values and command parameters are revisions
13509
8aea95ec128f bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents: 13243
diff changeset
573 _hg_labels
3993
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
574 return
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
575 }
04d919cdf263 expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3992
diff changeset
576
9511
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
577 # shelve
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
578 _hg_shelves()
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
579 {
11646
91af149b5cd7 bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents: 10456
diff changeset
580 local shelves="$(_hg_cmd unshelve -l .)"
9511
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
581 local IFS=$'\n'
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
582 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur"))
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
583 }
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
584
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
585 _hg_cmd_shelve()
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
586 {
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
587 _hg_status "mard"
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
588 }
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
589
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
590 _hg_cmd_unshelve()
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
591 {
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
592 _hg_shelves
33033af09308 bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents: 8719
diff changeset
593 }