# ktutil completion -*- shell-script -*- proc _heimdal_principals { setglobal COMPREPLY = ''( $( compgen -W "$( kadmin -l dump 2>/dev/null | \ awk '{print $1}' )" -- "$cur" ) ) } proc _heimdal_realms { setglobal COMPREPLY = ''( $( compgen -W "( kadmin -l dump 2>/dev/null | \ awk '{print $1}' | awk -F@ '{print $2}' )" -- "$cur" ) ) } proc _heimdal_encodings { setglobal COMPREPLY = ''( $( compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96' -- "$cur" ) ) } proc _ktutil { local cur prev words cword split _init_completion -s || return local command options match $prev { with -p|--principal _heimdal_principals return 0 with -e|--enctype _heimdal_encodings return 0 with -a|--admin-server _known_hosts_real $cur return 0 with -r|--realm _heimdal_realms return 0 with -s|-k|--srvtab|--keytab _filedir return 0 } $split && return 0 setglobal commands = ''add change copy get list remove rename purge srvconvert srv2keytab srvcreate key2srvtab'' for (( i=1; i < cword; i++ )); do case ${words[i]} in -k|--keytab) i=$(($i+1)) ;; -*) ;; *) command=${words[i]} break ;; esac done if [[ "$cur" == -* ]] { match $command { with add setglobal options = ''-p --principal -V -e --enctype -w --password -r --random -s --no-salt -h --hex'' with change setglobal options = ''-r --realm -a --admin-server -s --server-port'' with get setglobal options = ''-p --principal -e --enctype -r --realm -a --admin-server -s server --server-port'' with list setglobal options = ''--keys --timestamp'' with remove setglobal options = ''-p --principal -V --kvno -e --enctype'' with purge setglobal options = ''--age'' with srv2keytab|key2srvtab setglobal options = ''-s --srvtab'' with * setglobal options = ''-k --keytab -v --verbose --version -v --help'' } setglobal COMPREPLY = ''( $( compgen -W "$options" -- "$cur" ) ) } else { match $command { with copy _filedir with get _heimdal_principals with rename _heimdal_principals with * setglobal COMPREPLY = ''( $( compgen -W "$commands" -- "$cur" ) ) } } } && complete -F _ktutil ktutil # ex: ts=4 sw=4 et filetype=sh