]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - bash_completion/autorandr
Print configuration differences for failed actions if --debug is set
[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 --dry-run"
13         if [ -d ~/.autorandr ]; then
14                 prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
15         elif [ -d ~/.config/autorandr ]; then
16                 prfls="`find ~/.config/autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
17         else
18                 prfls=""
19         fi
20
21         case "${cur}" in
22                 --*)
23                         COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
24                         return 0
25                         ;;
26                 -*)
27                         COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
28                         return 0
29                         ;;
30                 *)
31                         if [ $COMP_CWORD -eq 1 ]; then
32                                 COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
33                         fi
34                         ;;
35                 esac
36
37         case "${prev}" in
38                 -l|--load|-d|--default)
39                         COMPREPLY=( $( compgen -W "${prfls}" -- $cur ) )
40                         return 0
41                         ;;
42                 *)
43                         ;;
44         esac
45
46         return 0
47 }
48 complete -F _autorandr autorandr