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