source: trunk/klask.bash_completion @ 234

Last change on this file since 234 was 234, checked in by g7moreau, 7 years ago
  • Add bash completion to klask
File size: 903 bytes
Line 
1# bash completion for klask
2
3_klask() {
4   local cur prev
5
6   COMPREPLY=()
7   #_get_comp_words_by_ref cur prev
8   cur="${COMP_WORDS[COMP_CWORD]}"
9   prev="${COMP_WORDS[COMP_CWORD-1]}"
10
11   case $prev in
12      -f|--format)
13         COMPREPLY=($(compgen -W "txt html dot" -- "$cur"))
14         return 0
15         ;;
16      -k|--kind)
17         COMPREPLY=($(compgen -W "host mac" -- "$cur"))
18         return 0
19         ;;
20      -i|--vlan)
21         COMPREPLY=($(compgen -W "$(grep vlan-id: /etc/klask/klask.conf|awk '{print $2}'|xargs echo -n)" -- "$cur"))
22         return 0
23         ;;
24   esac
25
26   if [[ "$cur" == -* ]]
27   then
28      COMPREPLY=($(compgen -W '-v --verbose -k --kind -f --format -d --day -i --vlan' -- "$cur"))
29   else
30      COMPREPLY=($(compgen -W "$($(which klask || echo /usr/sbin/klask) help|grep '^ klask'|awk '{print $2}'|xargs echo -n)" -- "$cur"))
31   fi
32
33   } && complete -F _klask klask
Note: See TracBrowser for help on using the repository browser.