2011-11-01 22:14:45 +02:00
|
|
|
# mcrypt(1) completion -*- shell-script -*-
|
|
|
|
# by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
|
2003-12-31 07:22:37 +00:00
|
|
|
|
2003-07-20 08:01:16 +00:00
|
|
|
_mcrypt()
|
|
|
|
{
|
2011-04-20 22:42:55 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2003-07-20 08:01:16 +00:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2009-11-22 11:43:26 +01:00
|
|
|
-g|--openpgp-z)
|
2011-04-25 23:44:08 +03:00
|
|
|
COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-o|--keymode)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \
|
|
|
|
2>/dev/null )' -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-m|--mode)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( mcrypt --list \
|
|
|
|
2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \
|
2009-12-09 23:55:27 +02:00
|
|
|
sort -u )" -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-a|--algorithm)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \
|
|
|
|
awk '{print $1}' )" -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-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
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-k|-s|--key|--keysize)
|
2009-10-04 19:42:50 +02:00
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
-f|-c|--keyfile|--config)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
--algorithms-directory|--modes-directory)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir -d
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2003-07-20 08:01:16 +00:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-04-29 12:26:46 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
2011-04-20 22:42:55 +03:00
|
|
|
elif [[ ${words[0]} == mdecrypt ]]; then
|
2010-08-20 13:35:12 +03:00
|
|
|
_filedir nc
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
2011-04-20 22:42:55 +03:00
|
|
|
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
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _mcrypt mcrypt mdecrypt
|
2009-10-01 20:54:51 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|