Show More
@@ -4,34 +4,34 b' shopt -s extglob' | |||
|
4 | 4 | { |
|
5 | 5 | "$hg" --debug help 2>/dev/null | \ |
|
6 | 6 | awk 'function command_line(line) { |
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
7 | gsub(/,/, "", line) | |
|
8 | gsub(/:.*/, "", line) | |
|
9 | split(line, aliases) | |
|
10 | command = aliases[1] | |
|
11 | delete aliases[1] | |
|
12 | print command | |
|
13 | for (i in aliases) | |
|
14 | if (index(command, aliases[i]) != 1) | |
|
15 | print aliases[i] | |
|
16 | } | |
|
17 | /^list of commands:/ {commands=1} | |
|
18 | commands && /^ debug/ {a[i++] = $0; next;} | |
|
19 | commands && /^ [^ ]/ {command_line($0)} | |
|
20 | /^global options:/ {exit 0} | |
|
21 | END {for (i in a) command_line(a[i])}' | |
|
22 | 22 | |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | _hg_option_list() |
|
26 | 26 | { |
|
27 |
"$hg" -v help $1 2> |
|
|
28 |
|
|
|
29 |
|
|
|
27 | "$hg" -v help $1 2>/dev/null | \ | |
|
28 | awk '/^ *-/ { | |
|
29 | for (i = 1; i <= NF; i ++) { | |
|
30 | 30 | if (index($i, "-") != 1) |
|
31 |
|
|
|
31 | break; | |
|
32 | 32 | print $i; |
|
33 |
|
|
|
34 |
|
|
|
33 | } | |
|
34 | }' | |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | |
@@ -56,29 +56,29 b' shopt -s extglob' | |||
|
56 | 56 | |
|
57 | 57 | _hg_paths() |
|
58 | 58 | { |
|
59 |
local paths="$("$hg" paths 2> |
|
|
60 |
COMPREPLY=(${COMPREPLY[@]:-} $( |
|
|
59 | local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')" | |
|
60 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) | |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | _hg_repos() |
|
64 | 64 | { |
|
65 | 65 | local i |
|
66 |
for i in $( |
|
|
67 |
|
|
|
66 | for i in $(compgen -d -- "$cur"); do | |
|
67 | test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i") | |
|
68 | 68 | done |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | _hg_status() |
|
72 | 72 | { |
|
73 |
local files="$( |
|
|
74 |
COMPREPLY=(${COMPREPLY[@]:-} $( |
|
|
73 | local files="$("$hg" status -n$1 . 2>/dev/null)" | |
|
74 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) | |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | _hg_tags() |
|
78 | 78 | { |
|
79 |
local tags="$("$hg" tags 2> |
|
|
80 |
|
|
|
81 |
COMPREPLY=( |
|
|
79 | local tags="$("$hg" tags 2>/dev/null | | |
|
80 | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" | |
|
81 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) | |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | # this is "kind of" ugly... |
@@ -87,7 +87,7 b' shopt -s extglob' | |||
|
87 | 87 | local i count=0 |
|
88 | 88 | local filters="$1" |
|
89 | 89 | |
|
90 |
for (( |
|
|
90 | for ((i=1; $i<=$COMP_CWORD; i++)); do | |
|
91 | 91 | if [[ "${COMP_WORDS[i]}" != -* ]]; then |
|
92 | 92 | if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then |
|
93 | 93 | continue |
@@ -113,7 +113,7 b' shopt -s extglob' | |||
|
113 | 113 | # searching for the command |
|
114 | 114 | # (first non-option argument that doesn't follow a global option that |
|
115 | 115 | # receives an argument) |
|
116 |
for (( |
|
|
116 | for ((i=1; $i<=$COMP_CWORD; i++)); do | |
|
117 | 117 | if [[ ${COMP_WORDS[i]} != -* ]]; then |
|
118 | 118 | if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
|
119 | 119 | cmd="${COMP_WORDS[i]}" |
@@ -125,7 +125,7 b' shopt -s extglob' | |||
|
125 | 125 | if [[ "$cur" == -* ]]; then |
|
126 | 126 | opts=$(_hg_option_list $cmd) |
|
127 | 127 | |
|
128 |
COMPREPLY=( |
|
|
128 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) | |
|
129 | 129 | return |
|
130 | 130 | fi |
|
131 | 131 | |
@@ -147,7 +147,7 b' shopt -s extglob' | |||
|
147 | 147 | fi |
|
148 | 148 | |
|
149 | 149 | # canonicalize command name |
|
150 |
cmd=$("$hg" -q help "$cmd" 2> |
|
|
150 | cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q') | |
|
151 | 151 | |
|
152 | 152 | if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then |
|
153 | 153 | _hg_tags |
@@ -191,17 +191,17 b' shopt -s extglob' | |||
|
191 | 191 | if [ $count = 1 ]; then |
|
192 | 192 | _hg_paths |
|
193 | 193 | fi |
|
194 |
|
|
|
194 | _hg_repos | |
|
195 | 195 | ;; |
|
196 | 196 | debugindex|debugindexdot) |
|
197 |
COMPREPLY=(${COMPREPLY[@]:-} $( |
|
|
197 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) | |
|
198 | 198 | ;; |
|
199 | 199 | debugdata) |
|
200 |
COMPREPLY=(${COMPREPLY[@]:-} $( |
|
|
200 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) | |
|
201 | 201 | ;; |
|
202 | 202 | esac |
|
203 | 203 | |
|
204 | 204 | } |
|
205 | 205 | |
|
206 |
complete -o bashdefault -o default -F _hg hg 2> |
|
|
206 | complete -o bashdefault -o default -F _hg hg 2>/dev/null \ | |
|
207 | 207 | || complete -o default -F _hg hg |
General Comments 0
You need to be logged in to leave comments.
Login now