85 lines
2.4 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
2009-06-08 21:22:43 +03:00
have mcrypt || have mdecrypt &&
_mcrypt()
{
2009-10-04 19:42:50 +02:00
local cur prev i decrypt
2009-10-04 19:42:50 +02:00
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-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
;;
-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 '--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
} &&
complete -o filenames -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