# mcrypt(1) completion -*- shell-script -*- # by Ariel Fermani proc _mcrypt { local cur prev words cword _init_completion || return match $prev { with -g|--openpgp-z setglobal COMPREPLY = ''( $( compgen -W '{0..9}' -- "$cur" ) ) return 0 with -o|--keymode setglobal COMPREPLY = ''( $( compgen -W '$( $1 --list-keymodes \ 2>/dev/null )' -- "$cur" ) ) return 0 with -m|--mode setglobal COMPREPLY = ''( $( compgen -W "$( $1 --list 2>/dev/null | \ cut -d: -f2- )" -- "$cur" ) ) return 0 with -a|--algorithm setglobal COMPREPLY = ''( $( compgen -W "$( $1 --list 2>/dev/null | \ awk '{print $1}' )" -- "$cur" ) ) return 0 with -h|--hash setglobal COMPREPLY = ''( $( compgen -W '$( $1 --list-hash 2>/dev/null | \ sed -e 1d )' -- "$cur" ) ) return 0 with -k|-s|--key|--keysize return 0 with -f|-c|--keyfile|--config _filedir return 0 with --algorithms-directory|--modes-directory _filedir -d return 0 } if [[ "$cur" == -* ]] { setglobal COMPREPLY = ''( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) } elif [[ ${words[0]} == mdecrypt ]] { _filedir nc } else { local i decrypt=0 for (( i=1; i < ${#words[@]}-1; i++ )); do if [[ ${words[i]} == -@(d|-decrypt) ]]; then _filedir nc decrypt=1 break fi done if [[ $decrypt -eq 0 ]] { _filedir } } } && complete -F _mcrypt mcrypt mdecrypt # ex: ts=4 sw=4 et filetype=sh