Show More
@@ -56,20 +56,23 b'' | |||
|
56 | 56 | _hg() |
|
57 | 57 | { |
|
58 | 58 | local cur prev cmd opts i |
|
59 | # global options that receive an argument | |
|
60 | local global_args='--cwd|-R|--repository' | |
|
59 | 61 | |
|
60 | 62 | COMPREPLY=() |
|
61 | 63 | cur="$2" |
|
62 | 64 | prev="$3" |
|
63 | 65 | |
|
64 | 66 | # searching for the command |
|
65 |
# (first non-option argument that doesn't follow |
|
|
67 | # (first non-option argument that doesn't follow a global option that | |
|
68 | # receives an argument) | |
|
66 | 69 | for (( i=1; $i<=$COMP_CWORD; i++ )); do |
|
67 |
if [[ ${COMP_WORDS[i]} != -* ]] |
|
|
68 |
|
|
|
69 | && [ "${COMP_WORDS[i-1]}" != --repository ]; then | |
|
70 | if [[ ${COMP_WORDS[i]} != -* ]]; then | |
|
71 | if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then | |
|
70 | 72 |
|
|
71 | 73 |
|
|
72 | 74 | fi |
|
75 | fi | |
|
73 | 76 | done |
|
74 | 77 | |
|
75 | 78 | if [[ "$cur" == -* ]]; then |
@@ -80,10 +83,17 b'' | |||
|
80 | 83 | return |
|
81 | 84 | fi |
|
82 | 85 | |
|
83 | if [ "$prev" = -R ] || [ "$prev" = --repository ]; then | |
|
86 | # global options | |
|
87 | case "$prev" in | |
|
88 | -R|--repository) | |
|
84 | 89 |
|
|
85 | 90 | return |
|
86 | fi | |
|
91 | ;; | |
|
92 | --cwd) | |
|
93 | COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" )) | |
|
94 | return | |
|
95 | ;; | |
|
96 | esac | |
|
87 | 97 | |
|
88 | 98 | if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then |
|
89 | 99 | _hg_commands |
General Comments 0
You need to be logged in to leave comments.
Login now