##// END OF EJS Templates
teach bash_completion about --cwd
Alexis S. L. Carvalho -
r1151:10b4f2a5 default
parent child Browse files
Show More
@@ -56,19 +56,22 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 -R/--repository)
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 && [ "${COMP_WORDS[i-1]}" != -R ] \
69 && [ "${COMP_WORDS[i-1]}" != --repository ]; then
70 cmd="${COMP_WORDS[i]}"
71 break
70 if [[ ${COMP_WORDS[i]} != -* ]]; then
71 if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
72 cmd="${COMP_WORDS[i]}"
73 break
74 fi
72 75 fi
73 76 done
74 77
@@ -80,10 +83,17 b''
80 83 return
81 84 fi
82 85
83 if [ "$prev" = -R ] || [ "$prev" = --repository ]; then
84 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
85 return
86 fi
86 # global options
87 case "$prev" in
88 -R|--repository)
89 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
90 return
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