2003-07-20 08:01:16 +00:00
|
|
|
# mcrypt(1) completion by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
|
2003-12-31 07:22:37 +00:00
|
|
|
|
2009-06-08 21:22:43 +03:00
|
|
|
have mcrypt || have mdecrypt &&
|
2003-07-20 08:01:16 +00:00
|
|
|
_mcrypt()
|
|
|
|
{
|
2009-10-04 19:42:50 +02:00
|
|
|
local cur prev i decrypt
|
2003-07-20 08:01:16 +00:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=()
|
2010-02-08 17:25:08 +01:00
|
|
|
_get_comp_words_by_ref cur prev
|
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)
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
|
|
|
|
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
|
2009-10-18 22:12:37 +03:00
|
|
|
COMPREPLY=( $( compgen -W '--openpgp --openpgp-z \
|
|
|
|
--decrypt --keysize --keymode --keyfile \
|
|
|
|
--config --algorithm --algorithms-directory \
|
|
|
|
--mode --modes-directory --hash --key \
|
|
|
|
--noiv --bare --gzip --bzip2 --flush \
|
|
|
|
--doublecheck --unlink --nodelete --time \
|
|
|
|
--force --echo --random --list --list-keymodes \
|
|
|
|
--list-hash --verbose --quiet --help \
|
|
|
|
--version --license' -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
elif [[ ${COMP_WORDS[0]} == mdecrypt ]]; then
|
2010-08-20 13:35:12 +03:00
|
|
|
_filedir nc
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
|
|
|
decrypt=0
|
|
|
|
for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
|
|
|
if [[ ${COMP_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
|
|
|
} &&
|
2009-10-22 12:04:29 +03:00
|
|
|
complete -o filenames -F _mcrypt mcrypt mdecrypt
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|