~ubuntu-branches/ubuntu/vivid/bash-completion/vivid-proposed

« back to all changes in this revision

Viewing changes to completions/mcrypt

  • Committer: Package Import Robot
  • Author(s): David Paleino
  • Date: 2011-02-06 22:00:58 UTC
  • mfrom: (1.1.4)
  • mto: (5.1.9 sid)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20110206220058-zfh1gyor3vp1goqc
Tags: 1:1.3-1
* New upstream release
  - Fixed "service" completion, thanks to John Hedges (Closes: #586210)
  - Fixed typo in openssl completion (Closes: #609552)
  - Added ip completion (Closes: #600617)
  - Added _tilde(), fix ~username completion (Closes: #587095)
  - Add *.webm to mplayer file completions (Closes: #588079).
* debian/watch: fix to handle .tar.bz2 files
* Bump Standards-Version to 3.9.1, no changes needed
* Install upstream CHANGES file
* Update copyright years in debian/copyright
* debian/rules: reflect new source layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# mcrypt(1) completion by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
 
2
 
 
3
have mcrypt || have mdecrypt &&
 
4
_mcrypt()
 
5
{
 
6
    local cur prev i decrypt
 
7
 
 
8
    COMPREPLY=()
 
9
    _get_comp_words_by_ref cur prev
 
10
 
 
11
    case $prev in
 
12
        -g|--openpgp-z)
 
13
            COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- "$cur" ) )
 
14
            return 0
 
15
            ;;
 
16
        -o|--keymode)
 
17
            COMPREPLY=( $( compgen -W '$( mcrypt --list-keymodes \
 
18
                2>/dev/null )' -- "$cur" ) )
 
19
            return 0
 
20
            ;;
 
21
        -m|--mode)
 
22
            COMPREPLY=( $( compgen -W "$( mcrypt --list \
 
23
                2>/dev/null | sed -e 's/.*: //' -e 's/ $//' | \
 
24
                sort -u )" -- "$cur" ) )
 
25
            return 0
 
26
            ;;
 
27
        -a|--algorithm)
 
28
            COMPREPLY=( $( compgen -W "$( mcrypt --list 2>/dev/null | \
 
29
                awk '{print $1}' )" -- "$cur" ) )
 
30
            return 0
 
31
            ;;
 
32
        -h|--hash)
 
33
            COMPREPLY=( $( compgen -W '$( mcrypt --list-hash 2>/dev/null | \
 
34
                sed -e 1d )' -- "$cur" ) )
 
35
            return 0
 
36
            ;;
 
37
        -k|-s|--key|--keysize)
 
38
            return 0
 
39
            ;;
 
40
        -f|-c|--keyfile|--config)
 
41
            _filedir
 
42
            return 0
 
43
            ;;
 
44
        --algorithms-directory|--modes-directory)
 
45
            _filedir -d
 
46
            return 0
 
47
            ;;
 
48
    esac
 
49
 
 
50
    if [[ "$cur" == -* ]]; then
 
51
        COMPREPLY=( $( compgen -W '--openpgp --openpgp-z \
 
52
            --decrypt --keysize --keymode --keyfile \
 
53
            --config --algorithm --algorithms-directory \
 
54
            --mode --modes-directory --hash --key \
 
55
            --noiv --bare --gzip --bzip2 --flush \
 
56
            --doublecheck --unlink --nodelete --time \
 
57
            --force --echo --random --list --list-keymodes \
 
58
            --list-hash --verbose --quiet --help \
 
59
            --version --license' -- "$cur" ) )
 
60
    elif [[ ${COMP_WORDS[0]} == mdecrypt ]]; then
 
61
        _filedir nc
 
62
    else
 
63
        decrypt=0
 
64
        for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
 
65
            if [[ ${COMP_WORDS[i]} == -@(d|-decrypt) ]]; then
 
66
                _filedir nc
 
67
                decrypt=1
 
68
                break
 
69
            fi
 
70
        done
 
71
        if [[ $decrypt -eq 0 ]]; then
 
72
            _filedir
 
73
        fi
 
74
    fi
 
75
} &&
 
76
complete -F _mcrypt mcrypt mdecrypt
 
77
 
 
78
# Local variables:
 
79
# mode: shell-script
 
80
# sh-basic-offset: 4
 
81
# sh-indent-comment: t
 
82
# indent-tabs-mode: nil
 
83
# End:
 
84
# ex: ts=4 sw=4 et filetype=sh