Mercurial > hg
annotate contrib/bash_completion @ 45074:797ef6f8295e
fix: prefetch file contents
This prevents the worker subprocesses from contacting the server individually,
which is either inefficient, or leads to problems if the connection is shared
among them.
Differential Revision: https://phab.mercurial-scm.org/D8723
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Thu, 09 Jul 2020 20:46:52 -0700 |
parents | f71c8eea7161 |
children |
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 | 62 _hg_commands() |
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 | 67 } |
68 | |
69 _hg_paths() | |
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 | 73 } |
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 |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
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 |
18793
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
83 _hg_debugpathcomplete() |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
84 { |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
85 local files="$(_hg_cmd debugpathcomplete $1 "$cur")" |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
86 local IFS=$'\n' |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
87 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
88 } |
a821ec835223
completion: selectively use debugpathcomplete in bash_completion
Bryan O'Sullivan <bryano@fb.com>
parents:
18790
diff
changeset
|
89 |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
90 _hg_status() |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
91 { |
30199
ba22059602e3
bashcompletion: allow skipping completion for 'hg status'
Mathias De Maré <mathias.de_mare@nokia.com>
parents:
29386
diff
changeset
|
92 if [ -z "$HGCOMPLETE_NOSTATUS" ]; then |
ba22059602e3
bashcompletion: allow skipping completion for 'hg status'
Mathias De Maré <mathias.de_mare@nokia.com>
parents:
29386
diff
changeset
|
93 local files="$(_hg_cmd status -n$1 "glob:$cur**")" |
ba22059602e3
bashcompletion: allow skipping completion for 'hg status'
Mathias De Maré <mathias.de_mare@nokia.com>
parents:
29386
diff
changeset
|
94 local IFS=$'\n' |
ba22059602e3
bashcompletion: allow skipping completion for 'hg status'
Mathias De Maré <mathias.de_mare@nokia.com>
parents:
29386
diff
changeset
|
95 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
ba22059602e3
bashcompletion: allow skipping completion for 'hg status'
Mathias De Maré <mathias.de_mare@nokia.com>
parents:
29386
diff
changeset
|
96 fi |
935
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
97 } |
925563ff1b18
bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents:
929
diff
changeset
|
98 |
20131
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
99 _hg_branches() |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
100 { |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
101 local branches="$(_hg_cmd branches -q)" |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
102 local IFS=$'\n' |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
103 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur")) |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
104 } |
56df59cc4212
bash_completion: add _hg_branches for list of branches
Sean Farley <sean.michael.farley@gmail.com>
parents:
20130
diff
changeset
|
105 |
13509
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
106 _hg_bookmarks() |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
107 { |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
108 local bookmarks="$(_hg_cmd bookmarks -q)" |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
109 local IFS=$'\n' |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
110 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur")) |
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 |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
113 _hg_labels() |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
114 { |
23762
0390cc327dd5
debugnamecomplete: rename from debuglabelcomplete
Sean Farley <sean.michael.farley@gmail.com>
parents:
21719
diff
changeset
|
115 local labels="$(_hg_cmd debugnamecomplete "$cur")" |
18790
1e28a7f58f33
completion: add a debuglabelcomplete command
Bryan O'Sullivan <bryano@fb.com>
parents:
18789
diff
changeset
|
116 local IFS=$'\n' |
1e28a7f58f33
completion: add a debuglabelcomplete command
Bryan O'Sullivan <bryano@fb.com>
parents:
18789
diff
changeset
|
117 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$labels' -- "$cur")) |
13509
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
118 } |
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
119 |
916 | 120 # this is "kind of" ugly... |
121 _hg_count_non_option() | |
122 { | |
123 local i count=0 | |
124 local filters="$1" | |
125 | |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
126 for ((i=1; $i<=$COMP_CWORD; i++)); do |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
127 if [[ "${COMP_WORDS[i]}" != -* ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
128 if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
129 continue |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
130 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
131 count=$(($count + 1)) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
132 fi |
916 | 133 done |
134 | |
135 echo $(($count - 1)) | |
136 } | |
137 | |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
138 _hg_fix_wordlist() |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
139 { |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
140 local LASTCHAR=' ' |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
141 if [ ${#COMPREPLY[@]} = 1 ]; then |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
142 [ -d "$COMPREPLY" ] && LASTCHAR=/ |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
143 COMPREPLY=$(printf %q%s "$COMPREPLY" "$LASTCHAR") |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
144 else |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
145 for ((i=0; i < ${#COMPREPLY[@]}; i++)); do |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
146 [ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/ |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
147 done |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
148 fi |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
149 } |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
150 |
916 | 151 _hg() |
152 { | |
20125
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
153 local cur prev cmd cmd_index opts i aliashg |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
154 # global options that receive an argument |
39398
8ab79580047f
bash_completion: add more global options that receive an argument
Anton Shestakov <av6@dwimlabs.net>
parents:
35457
diff
changeset
|
155 local global_args='--cwd|-R|--repository|--color|--config|--encoding|--encodingmode|--pager' |
1683
063e04831a09
Use user specified path to hg in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1643
diff
changeset
|
156 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
|
157 local canonical=0 |
916 | 158 |
20125
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
159 aliashg=$(alias $hg 2>/dev/null) |
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
160 if [[ -n "$aliashg" ]]; then |
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
161 aliashg=${aliashg#"alias $hg='"} |
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
162 aliashg=${aliashg%"'"} |
44820
f71c8eea7161
bash_completion: do not use aliased hg if it sources a script (issue6308)
Peter Arrenbrecht <peter@arrenbrecht.ch>
parents:
39399
diff
changeset
|
163 # `source`d aliases break completion, so ignore them |
f71c8eea7161
bash_completion: do not use aliased hg if it sources a script (issue6308)
Peter Arrenbrecht <peter@arrenbrecht.ch>
parents:
39399
diff
changeset
|
164 if [[ "${aliashg:0:7}" != "source " ]]; then |
f71c8eea7161
bash_completion: do not use aliased hg if it sources a script (issue6308)
Peter Arrenbrecht <peter@arrenbrecht.ch>
parents:
39399
diff
changeset
|
165 hg=$aliashg |
f71c8eea7161
bash_completion: do not use aliased hg if it sources a script (issue6308)
Peter Arrenbrecht <peter@arrenbrecht.ch>
parents:
39399
diff
changeset
|
166 fi |
20125
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
167 fi |
191ab08e7099
bash_completion: determine root executable in case of alias
Sean Farley <sean.michael.farley@gmail.com>
parents:
20124
diff
changeset
|
168 |
916 | 169 COMPREPLY=() |
170 cur="$2" | |
171 prev="$3" | |
172 | |
1308
2073e5a71008
Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1263
diff
changeset
|
173 # searching for the command |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
174 # (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
|
175 # receives an argument) |
1684
cf930b2452d3
Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1683
diff
changeset
|
176 for ((i=1; $i<=$COMP_CWORD; i++)); do |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
177 if [[ ${COMP_WORDS[i]} != -* ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
178 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
179 cmd="${COMP_WORDS[i]}" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
180 cmd_index=$i |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
181 break |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
182 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
183 fi |
916 | 184 done |
185 | |
186 if [[ "$cur" == -* ]]; then | |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
187 if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
188 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
189 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
190 fi |
3485
26285469db9b
bash_completion: allow overriding completion for arguments that start with "-"
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3484
diff
changeset
|
191 |
29386
63fad6235369
bashcompletion: show available command-line switches for aliases
Martijn Pieters <mjpieters@fb.com>
parents:
26904
diff
changeset
|
192 opts=$(HGPLAINEXCEPT=alias _hg_cmd debugcomplete --options "$cmd") |
916 | 193 |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
194 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
195 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
196 return |
916 | 197 fi |
198 | |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
199 # global options |
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
200 case "$prev" in |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
201 -R|--repository) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
202 _hg_paths |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
203 _hg_repos |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
204 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
205 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
206 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
207 --cwd) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
208 # Stick with default bash completion |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
209 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
210 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
211 ;; |
39399
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
212 --color) |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
213 local choices='true false yes no always auto never debug' |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
214 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$choices' -- "$cur")) |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
215 _hg_fix_wordlist |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
216 return |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
217 ;; |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
218 --pager) |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
219 local choices='true false yes no always auto never' |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
220 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$choices' -- "$cur")) |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
221 _hg_fix_wordlist |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
222 return |
c54d4607e8aa
bash_completion: complete arguments for --color and --pager
Anton Shestakov <av6@dwimlabs.net>
parents:
39398
diff
changeset
|
223 ;; |
1151
10b4f2a5ce17
teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1150
diff
changeset
|
224 esac |
916 | 225 |
226 if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then | |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
227 _hg_commands |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
228 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
229 return |
916 | 230 fi |
231 | |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
232 # 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
|
233 local help |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
234 if _hg_command_specific; then |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
235 _hg_fix_wordlist |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
236 return |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
237 fi |
1150
4ee09418c8e5
bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
1149
diff
changeset
|
238 |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
239 # 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
|
240 help=$(_hg_cmd help "$cmd") |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
241 if [ $? -ne 0 ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
242 # Probably either the command doesn't exist or it's ambiguous |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
243 return |
916 | 244 fi |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
245 cmd=${help#hg } |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
246 cmd=${cmd%%[$' \n']*} |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
247 canonical=1 |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
248 _hg_command_specific |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
249 _hg_fix_wordlist |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
250 } |
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 _hg_command_specific() |
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
253 { |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
254 if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
255 "_hg_cmd_$cmd" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
256 return 0 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
257 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
258 |
20133
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
259 if [ "$cmd" != status ]; then |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
260 case "$prev" in |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
261 -r|--rev) |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
262 if [[ $canonical = 1 || status != "$cmd"* ]]; then |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
263 _hg_labels |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
264 return 0 |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
265 fi |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
266 return 1 |
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
267 ;; |
20134
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
268 -B|--bookmark) |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
269 if [[ $canonical = 1 || status != "$cmd"* ]]; then |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
270 _hg_bookmarks |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
271 return 0 |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
272 fi |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
273 return 1 |
bc9735855598
bash_completion: add global support for -B|--bookmark
Sean Farley <sean.michael.farley@gmail.com>
parents:
20133
diff
changeset
|
274 ;; |
20135
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
275 -b|--branch) |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
276 if [[ $canonical = 1 || status != "$cmd"* ]]; then |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
277 _hg_branches |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
278 return 0 |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
279 fi |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
280 return 1 |
e39bd4b7be78
bash_completion: add global support for -b|--branch
Sean Farley <sean.michael.farley@gmail.com>
parents:
20134
diff
changeset
|
281 ;; |
20133
f6c33fc59dbd
bash_completion: change --rev if-else block into a case
Sean Farley <sean.michael.farley@gmail.com>
parents:
20132
diff
changeset
|
282 esac |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
283 fi |
916 | 284 |
20124
dd3af304b3c8
bash_completion: expand aliased commands
Sean Farley <sean.michael.farley@gmail.com>
parents:
20123
diff
changeset
|
285 local aliascmd=$(_hg_cmd showconfig alias.$cmd | awk '{print $1}') |
dd3af304b3c8
bash_completion: expand aliased commands
Sean Farley <sean.michael.farley@gmail.com>
parents:
20123
diff
changeset
|
286 [ -n "$aliascmd" ] && cmd=$aliascmd |
dd3af304b3c8
bash_completion: expand aliased commands
Sean Farley <sean.michael.farley@gmail.com>
parents:
20123
diff
changeset
|
287 |
916 | 288 case "$cmd" in |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
289 help) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
290 _hg_commands |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
291 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
292 export) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
293 if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
294 return 0 |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
295 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
296 _hg_labels |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
297 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
298 manifest|update|up|checkout|co) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
299 _hg_labels |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
300 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
301 pull|push|outgoing|incoming) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
302 _hg_paths |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
303 _hg_repos |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
304 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
305 paths) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
306 _hg_paths |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
307 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
308 add) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
309 _hg_status "u" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
310 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
311 merge) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
312 _hg_labels |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
313 ;; |
35457
2c47986505ff
completion: add support for new "amend" command
Martin von Zweigbergk <martinvonz@google.com>
parents:
35456
diff
changeset
|
314 commit|ci|record|amend) |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
315 _hg_status "mar" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
316 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
317 remove|rm) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
318 _hg_debugpathcomplete -n |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
319 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
320 forget) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
321 _hg_debugpathcomplete -fa |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
322 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
323 diff) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
324 _hg_status "mar" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
325 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
326 revert) |
35456
fdbe4eafa9c2
completion: don't suggest clean files to revert
Martin von Zweigbergk <martinvonz@google.com>
parents:
30199
diff
changeset
|
327 _hg_status "mard" |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
328 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
329 clone) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
330 local count=$(_hg_count_non_option) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
331 if [ $count = 1 ]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
332 _hg_paths |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
333 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
334 _hg_repos |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
335 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
336 debugindex|debugindexdot) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
337 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
338 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
339 debugdata) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
340 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
341 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
342 *) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
343 return 1 |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
344 ;; |
916 | 345 esac |
346 | |
2039
0c438fd25e6e
bash_completion: small optimization
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2035
diff
changeset
|
347 return 0 |
916 | 348 } |
349 | |
20126
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
350 complete -o bashdefault -o default -o nospace -F _hg hg \ |
25cb1d96c307
bash_completion: fix issue with subdirectories not being completed
Sean Farley <sean.michael.farley@gmail.com>
parents:
20125
diff
changeset
|
351 || complete -o default -o nospace -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
|
352 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
353 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
354 # 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
|
355 |
9460
552c5a5a3502
contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents:
8719
diff
changeset
|
356 # bookmarks |
552c5a5a3502
contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents:
8719
diff
changeset
|
357 _hg_cmd_bookmarks() |
552c5a5a3502
contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents:
8719
diff
changeset
|
358 { |
20127
6b771bcd1a62
bash_completion: remove restriction on bookmark completion
Sean Farley <sean.michael.farley@gmail.com>
parents:
20126
diff
changeset
|
359 _hg_bookmarks |
6b771bcd1a62
bash_completion: remove restriction on bookmark completion
Sean Farley <sean.michael.farley@gmail.com>
parents:
20126
diff
changeset
|
360 return |
9460
552c5a5a3502
contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents:
8719
diff
changeset
|
361 } |
552c5a5a3502
contrib/bash_completion: add tab completion for some bookmark commands
Steve Losh <steve@stevelosh.com>
parents:
8719
diff
changeset
|
362 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
363 # mq |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
364 _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
|
365 { |
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
|
366 local patches |
11646
91af149b5cd7
bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents:
10456
diff
changeset
|
367 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
|
368 if [ $? -eq 0 ] && [ "$patches" ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
369 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur")) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
370 return 0 |
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
|
371 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
|
372 return 1 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
373 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
374 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
375 _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
|
376 { |
11646
91af149b5cd7
bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents:
10456
diff
changeset
|
377 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
|
378 local n |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
379 for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
380 # I think we're usually not interested in the regular "patches" queue |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
381 # so just filter it. |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
382 if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
383 COMPREPLY=(${COMPREPLY[@]:-} "$n") |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
384 fi |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
385 done |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
386 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
387 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
388 _hg_cmd_qpop() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
389 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
390 if [[ "$prev" = @(-n|--name) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
391 _hg_ext_mq_queues |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
392 return |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
393 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
394 _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
|
395 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
396 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
397 _hg_cmd_qpush() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
398 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
399 if [[ "$prev" = @(-n|--name) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
400 _hg_ext_mq_queues |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
401 return |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
402 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
403 _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
|
404 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
405 |
5507
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
406 _hg_cmd_qgoto() |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
407 { |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
408 if [[ "$prev" = @(-n|--name) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
409 _hg_ext_mq_queues |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
410 return |
5507
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
411 fi |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
412 _hg_ext_mq_patchlist qseries |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
413 } |
bb417470d62a
Support qgoto in contrib/bash_completion.
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5081
diff
changeset
|
414 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
415 _hg_cmd_qdelete() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
416 { |
3482
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
417 local qcmd=qunapplied |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
418 if [[ "$prev" = @(-r|--rev) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
419 qcmd=qapplied |
3482
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
420 fi |
e762c0e95eac
bash_completion: qdelete --rev
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3481
diff
changeset
|
421 _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
|
422 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
423 |
9840
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
424 _hg_cmd_qfinish() |
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
425 { |
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
426 if [[ "$prev" = @(-a|--applied) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
427 return |
9840
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
428 fi |
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
429 _hg_ext_mq_patchlist qapplied |
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
430 } |
18d5935c0c62
Add missing bash_completion for qfinish
Thomas Arendsen Hein <thomas@intevation.de>
parents:
9602
diff
changeset
|
431 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
432 _hg_cmd_qsave() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
433 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
434 if [[ "$prev" = @(-n|--name) ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
435 _hg_ext_mq_queues |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
436 return |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
437 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
438 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
439 |
17463
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
440 _hg_cmd_rebase() { |
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
441 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
|
442 _hg_labels |
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
443 return |
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
444 fi |
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
445 } |
e49771e2d071
bash_completion: add rebase rev completion
Kevin Bullock <kbullock@ringworld.org>
parents:
15969
diff
changeset
|
446 |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
447 _hg_cmd_strip() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
448 { |
20130
7c78c7eff119
bash_completion: add -B|--bookmark support for strip
Sean Farley <sean.michael.farley@gmail.com>
parents:
20129
diff
changeset
|
449 if [[ "$prev" = @(-B|--bookmark) ]]; then |
7c78c7eff119
bash_completion: add -B|--bookmark support for strip
Sean Farley <sean.michael.farley@gmail.com>
parents:
20129
diff
changeset
|
450 _hg_bookmarks |
7c78c7eff119
bash_completion: add -B|--bookmark support for strip
Sean Farley <sean.michael.farley@gmail.com>
parents:
20129
diff
changeset
|
451 return |
7c78c7eff119
bash_completion: add -B|--bookmark support for strip
Sean Farley <sean.michael.farley@gmail.com>
parents:
20129
diff
changeset
|
452 fi |
13509
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
453 _hg_labels |
2041
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 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
456 _hg_cmd_qcommit() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
457 { |
11646
91af149b5cd7
bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents:
10456
diff
changeset
|
458 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
|
459 # 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
|
460 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
|
461 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
|
462 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
463 |
3484
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
464 _hg_cmd_qfold() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
465 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
466 _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
|
467 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
468 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
469 _hg_cmd_qrename() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
470 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
471 _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
|
472 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
473 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
474 _hg_cmd_qheader() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
475 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
476 _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
|
477 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
478 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
479 _hg_cmd_qclone() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
480 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
481 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
|
482 if [ $count = 1 ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
483 _hg_paths |
3484
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
484 fi |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
485 _hg_repos |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
486 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
487 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
488 _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
|
489 { |
11646
91af149b5cd7
bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao <brodie@bitheap.org>
parents:
10456
diff
changeset
|
490 _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
|
491 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
492 |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
493 _hg_cmd_qselect() |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
494 { |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
495 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
|
496 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
|
497 } |
a8823e6824fc
bash_completion: qfold, qrename, qheader, qclone and qselect
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3483
diff
changeset
|
498 |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
499 _hg_cmd_qguard() |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
500 { |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
501 local prefix='' |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
502 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
503 if [[ "$cur" == +* ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
504 prefix=+ |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
505 elif [[ "$cur" == -* ]]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
506 prefix=- |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
507 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
508 local ncur=${cur#[-+]} |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
509 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
510 if ! [ "$prefix" ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
511 _hg_ext_mq_patchlist qseries |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
512 return |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
513 fi |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
514 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
515 local guards=$(_hg_ext_mq_guards) |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
516 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur")) |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
517 } |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
518 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
519 _hg_opt_qguard() |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
520 { |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
521 local i |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
522 for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
523 if [[ ${COMP_WORDS[i]} != -* ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
524 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
525 _hg_cmd_qguard |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
526 return 0 |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
527 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
528 elif [ "${COMP_WORDS[i]}" = -- ]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
529 _hg_cmd_qguard |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
530 return 0 |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
531 fi |
3486
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
532 done |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
533 return 1 |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
534 } |
f699d4eb25d9
bash_completion: qguard
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3485
diff
changeset
|
535 |
11768
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
536 _hg_cmd_qqueue() |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
537 { |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
538 local q |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
539 local queues |
11968
66521d25c2a6
mq/qqueue: update bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11768
diff
changeset
|
540 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
|
541 |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
542 queues=$( _hg_cmd qqueue --quiet ) |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
543 |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
544 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
|
545 } |
dc5ce9c95d00
mq/qqueue: enable bash completion
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
11646
diff
changeset
|
546 |
2041
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 # hbisect |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
549 _hg_cmd_bisect() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
550 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
551 local i subcmd |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
552 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
553 # 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
|
554 for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
555 if [[ ${COMP_WORDS[i]} != -* ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
556 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
557 subcmd="${COMP_WORDS[i]}" |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
558 break |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
559 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
560 fi |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
561 done |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
562 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
563 if [ -z "$subcmd" ] || [ $COMP_CWORD -eq $i ] || [ "$subcmd" = help ]; then |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
564 COMPREPLY=(${COMPREPLY[@]:-} |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
565 $(compgen -W 'bad good help init next reset' -- "$cur")) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
566 return |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
567 fi |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
568 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
569 case "$subcmd" in |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
570 good|bad) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
571 _hg_labels |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
572 ;; |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
573 esac |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
574 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
575 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
576 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
577 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
578 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
579 # patchbomb |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
580 _hg_cmd_email() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
581 { |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
582 case "$prev" in |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
583 -c|--cc|-t|--to|-f|--from|--bcc) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
584 # we need an e-mail address. let the user provide a function |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
585 # to get them |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
586 if [ "$(type -t _hg_emails)" = function ]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
587 local arg=to |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
588 if [[ "$prev" == @(-f|--from) ]]; then |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
589 arg=from |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
590 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
591 local addresses=$(_hg_emails $arg) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
592 COMPREPLY=(${COMPREPLY[@]:-} |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
593 $(compgen -W '$addresses' -- "$cur")) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
594 fi |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
595 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
596 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
597 -m|--mbox) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
598 # fallback to standard filename completion |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
599 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
600 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
601 -s|--subject) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
602 # free form string |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
603 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
604 ;; |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
605 esac |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
606 |
13509
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
607 _hg_labels |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
608 return |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
609 } |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
610 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
611 |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
612 # gpg |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
613 _hg_cmd_sign() |
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
614 { |
13509
8aea95ec128f
bash_completion: complete bookmarks
Kevin Bullock <kbullock@ringworld.org>
parents:
13243
diff
changeset
|
615 _hg_labels |
2041
077a2da7f1de
bash_completion: completion for commands provided by extensions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2039
diff
changeset
|
616 } |
3993
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
617 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
618 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
619 # transplant |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
620 _hg_cmd_transplant() |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
621 { |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
622 case "$prev" in |
20123
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
623 -s|--source) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
624 _hg_paths |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
625 _hg_repos |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
626 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
627 ;; |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
628 --filter) |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
629 # standard filename completion |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
630 return |
f16240c8e959
bash_completion: untabify
Sean Farley <sean.michael.farley@gmail.com>
parents:
18794
diff
changeset
|
631 ;; |
3993
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
632 esac |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
633 |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
634 # 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
|
635 _hg_labels |
3993
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
636 return |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
637 } |
04d919cdf263
expanded bash_completion for transplant extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3992
diff
changeset
|
638 |
9511
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
639 # shelve |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
640 _hg_shelves() |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
641 { |
20128
56108ee1edb6
bash_completion: use correct command for listing shelves
Sean Farley <sean.michael.farley@gmail.com>
parents:
20127
diff
changeset
|
642 local shelves="$(_hg_cmd shelve -ql)" |
9511
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
643 local IFS=$'\n' |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
644 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur")) |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
645 } |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
646 |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
647 _hg_cmd_shelve() |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
648 { |
26904
8aacac09e222
bash_completion: add -p|--patch|--stat support for shelve
Anton Shestakov <av6@dwimlabs.net>
parents:
23762
diff
changeset
|
649 if [[ "$prev" = @(-d|--delete|-l|--list|-p|--patch|--stat) ]]; then |
20129
da8fb88bd757
bash_completion: add completion for deleting a shelve
Sean Farley <sean.michael.farley@gmail.com>
parents:
20128
diff
changeset
|
650 _hg_shelves |
da8fb88bd757
bash_completion: add completion for deleting a shelve
Sean Farley <sean.michael.farley@gmail.com>
parents:
20128
diff
changeset
|
651 else |
da8fb88bd757
bash_completion: add completion for deleting a shelve
Sean Farley <sean.michael.farley@gmail.com>
parents:
20128
diff
changeset
|
652 _hg_status "mard" |
da8fb88bd757
bash_completion: add completion for deleting a shelve
Sean Farley <sean.michael.farley@gmail.com>
parents:
20128
diff
changeset
|
653 fi |
9511
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
654 } |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
655 |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
656 _hg_cmd_unshelve() |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
657 { |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
658 _hg_shelves |
33033af09308
bash_completion: add completions for shelve extension
Kevin Bullock <kbullock@ringworld.org>
parents:
8719
diff
changeset
|
659 } |