]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - bash_completion/autorandr
Merge branch 'patch-1' of https://github.com/vapniks/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         prfls=""
14         if [ -d ~/.autorandr/ ]; then
15                 prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
16         fi
17
18         case "${cur}" in
19                 --*)
20                         COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
21                         return 0
22                         ;;
23                 -*)
24                         COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
25                         return 0
26                         ;;
27                 *)
28                         if [ $COMP_CWORD -eq 1 ]; then
29                                 COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
30                         fi
31                         ;;
32                 esac
33
34         case "${prev}" in
35                 -l|--load|-d|--default)
36                         COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) )
37                         return 0
38                         ;;
39                 *)
40                         ;;
41         esac
42
43         return 0
44 }
45 complete -F _autorandr autorandr
46 complete -F _autorandr auto-disper
47