comparison bash_completion @ 0:a84c32f131df 1.1.29

Import vendor version
author Peter Gervai <grin@grin.hu>
date Wed, 15 Oct 2008 23:28:56 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a84c32f131df
1 # bins completion for bash
2 #-*- mode: shell-script;-*-
3 _bins()
4 {
5 local cur prev tempdir
6
7 COMPREPLY=()
8 cur=${COMP_WORDS[COMP_CWORD]}
9 prev=${COMP_WORDS[COMP_CWORD-1]}
10
11 case "$prev" in
12 -f)
13 _filedir
14 return 0
15 ;;
16 -o)
17 COMPREPLY=( $( compgen -W 'scaled copied custom' -- $cur ) )
18 return 0
19 ;;
20 -c)
21 conffile=$HOME/.bins/binsrc
22 for (( i=1; i < COMP_CWORD; i++ )); do
23 if [[ "${COMP_WORDS[i]}" == -f ]]; then
24 conffile=${COMP_WORDS[i+1]}
25 break
26 fi
27 done
28 COMPREPLY=( \
29 $( awk -F'"' '/<colors style="/ {print $2}' $conffile | grep "^$cur" ) \
30 $( awk -F"'" "/<colors style='/ {print $2}" $conffile | grep "^$cur" ) \
31 )
32 return 0
33 ;;
34 -t)
35 _filedir -d
36 return 0
37 ;;
38 -r)
39 COMPREPLY=( $( compgen -W 'dirs pictures dirs,pictures' -- $cur ) )
40 return 0
41 ;;
42 -s)
43 tempdir=/usr/share/bins
44 for (( i=1; i < COMP_CWORD; i++ )); do
45 if [[ "${COMP_WORDS[i]}" == -t ]]; then
46 tempdir=${COMP_WORDS[i+1]}
47 break
48 fi
49 done
50 COMPREPLY=( $( find $tempdir -type d -maxdepth 1 -name templates.* | \
51 sed -e "s|$tempdir/templates.||" | grep "^$cur" ) )
52 return 0
53 ;;
54 esac
55
56 if [[ "$cur" == -* ]]; then
57 COMPREPLY=( $( compgen -W '-f -o -d -c -s -t -p -r -e -i -n -v -h' -- $cur ) )
58 else
59 _filedir -d
60 fi
61
62 }
63 complete -F _bins bins