]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - bash_completion/autorandr
Merge http://github.com/voda/autorandr
[deb_pkgs/autorandr.git] / bash_completion / autorandr
1 # autorandr/auto-disper completion by Maciej 'macieks' Sitarz <macieks@freesco.pl>
2
3 _autorandr ()
4 {
5         local cur prev opts lopts prfls
6
7         COMPREPLY=()
8         cur="${COMP_WORDS[COMP_CWORD]}"
9         prev="${COMP_WORDS[COMP_CWORD-1]}"
10
11         opts="-h -c -s -l -d"
12         lopts="--help --change --save --load --default --force --fingerprint --config"
13         if [ -d ~/.autorandr ]; then
14                 prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
15         else
16                 prfls=""
17         fi
18
19         case "${cur}" in
20                 --*)
21                         COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
22                         return 0
23                         ;;
24                 -*)
25                         COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
26                         return 0
27                         ;;
28                 *)
29                         if [ $COMP_CWORD -eq 1 ]; then
30                                 COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
31                         fi
32                         ;;
33                 esac
34
35         case "${prev}" in
36                 -l|--load|-d|--default)
37                         COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) )
38                         return 0
39                         ;;
40                 *)
41                         ;;
42         esac
43
44         return 0
45 }
46 complete -F _autorandr autorandr
47 complete -F _autorandr auto-disper
48