comparison contrib/bash_completion @ 935:925563ff1b18

bash: Add smarter completion of add/commit/remove/forget/diff/revert Use hg status to determine which files are interesting for various commands. Thus, hg add [tab] finds unknown files, and hg commit [tab] finds added, modified, or removed files.
author mpm@selenic.com
date Wed, 17 Aug 2005 12:22:12 -0800
parents 26bb67b7ec14
children f15901d053e1 6d21a3488df9 ffb0665028f0 dbfabfcb485e 4f81068ed8cd
comparison
equal deleted inserted replaced
934:ff484cc157d6 935:925563ff1b18
15 15
16 _hg_paths() 16 _hg_paths()
17 { 17 {
18 local paths="$(hg paths | sed -e 's/ = .*$//')" 18 local paths="$(hg paths | sed -e 's/ = .*$//')"
19 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$paths" -- "$cur" )) 19 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$paths" -- "$cur" ))
20 }
21
22 _hg_status()
23 {
24 local files="$( hg status -$1 | cut -b 3- )"
25 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W "$files" -- "$cur" ))
20 } 26 }
21 27
22 _hg_tags() 28 _hg_tags()
23 { 29 {
24 local tags="$(hg tags | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" 30 local tags="$(hg tags | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')"
102 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" )) 108 COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
103 ;; 109 ;;
104 paths) 110 paths)
105 _hg_paths 111 _hg_paths
106 ;; 112 ;;
113 add)
114 _hg_status "u"
115 ;;
116 commit)
117 _hg_status "mra"
118 ;;
119 remove)
120 _hg_status "r"
121 ;;
122 forget)
123 _hg_status "a"
124 ;;
125 diff)
126 _hg_status "mra"
127 ;;
128 revert)
129 _hg_status "mra"
130 ;;
107 clone) 131 clone)
108 local count=$(_hg_count_non_option) 132 local count=$(_hg_count_non_option)
109 if [ $count = 1 ]; then 133 if [ $count = 1 ]; then
110 _hg_paths 134 _hg_paths
111 fi 135 fi
124 ;; 148 ;;
125 esac 149 esac
126 150
127 } 151 }
128 152
129 complete -o filenames -F _hg hg 153 complete -o default -F _hg hg