74 lines
1.9 KiB
Plaintext
Raw Normal View History

# mcrypt(1) completion by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
2003-12-31 07:22:37 +00:00
_mcrypt()
{
local cur prev words cword
_init_completion || return
case $prev in
-g|--openpgp-z)
COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-o|--keymode)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \
2>/dev/null )' -- "$cur" ) )
return 0
;;
-m|--mode)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W "$( mcrypt --list \
2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \
sort -u )" -- "$cur" ) )
2009-10-04 19:42:50 +02:00
return 0
;;
-a|--algorithm)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \
awk '{print $1}' )" -- "$cur" ) )
return 0
;;
-h|--hash)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W '$( mcrypt --list-hash 2>/dev/null | \
sed -e 1d )' -- "$cur" ) )
return 0
;;
-k|-s|--key|--keysize)
2009-10-04 19:42:50 +02:00
return 0
;;
-f|-c|--keyfile|--config)
2009-10-04 19:42:50 +02:00
_filedir
return 0
;;
--algorithms-directory|--modes-directory)
2009-10-04 19:42:50 +02:00
_filedir -d
return 0
;;
esac
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
elif [[ ${words[0]} == mdecrypt ]]; then
2010-08-20 13:35:12 +03:00
_filedir nc
2009-10-04 19:42:50 +02:00
else
local i decrypt=0
for (( i=1; i < ${#words[@]}-1; i++ )); do
if [[ ${words[i]} == -@(d|-decrypt) ]]; then
2010-08-20 13:35:12 +03:00
_filedir nc
2009-10-04 19:42:50 +02:00
decrypt=1
break
fi
done
if [[ $decrypt -eq 0 ]]; then
_filedir
fi
fi
2009-06-08 21:22:43 +03:00
} &&
complete -F _mcrypt mcrypt mdecrypt
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh