~plaxx/backintime/explicit-ssh-private-key

« back to all changes in this revision

Viewing changes to common/bash-completion/backintime

  • Committer: Germar
  • Date: 2015-02-24 12:09:46 UTC
  • Revision ID: germar-20150224120946-tqqo2j873s7zmhdu
add bash-completion

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
_bit_extr_opts()
 
2
{
 
3
    local last="" opts=""
 
4
    for i in "${COMP_WORDS}"; do
 
5
        case "${last}" in
 
6
            --profile|--profile-id|--config)
 
7
                if [[ ${i} != -* ]]; then
 
8
                    opts="${opts} ${last} ${i}"
 
9
                fi ;;
 
10
        esac
 
11
        last=${i}
 
12
    done
 
13
    echo "${opts}"
 
14
}
 
15
 
 
16
_bit_snapshots_list()
 
17
{
 
18
    backintime$(_bit_extr_opts) --quiet --snapshots-list | awk '{print $2}'
 
19
}
 
20
 
 
21
_backintime() 
 
22
{
 
23
    local cur prev actions opts pw_cache_commands
 
24
    COMPREPLY=()
 
25
    cur="${COMP_WORDS[COMP_CWORD]}"
 
26
    prev="${COMP_WORDS[COMP_CWORD-1]}"
 
27
    prev2="${COMP_WORDS[COMP_CWORD-2]}"
 
28
    prev3="${COMP_WORDS[COMP_CWORD-3]}"
 
29
    opts="--profile --profile-id --keep-mount --quiet --config --checksum"
 
30
    actions="--backup --backup-job --snapshots-path --snapshots-list --snapshots-list-path --last-snapshot --umount --benchmark-cipher --pw-cache --decode --remove --restore --version --license --help"
 
31
    pw_cache_commands="start stop restart reload status"
 
32
 
 
33
    if [[ "${prev2}" == "--restore" ]] && [[ ${prev} != -* ]] && [[ ${cur} != -* ]]; then
 
34
         _filedir
 
35
         return 0
 
36
    fi
 
37
 
 
38
    if [[ "${prev3}" == "--restore" ]] && [[ ${prev2} != -* ]] && [[ ${prev} != -* ]] && [[ ${cur} != -* ]]; then
 
39
         COMPREPLY=( $(compgen -W "$(_bit_snapshots_list)" -- ${cur}) )
 
40
         return 0
 
41
    fi
 
42
 
 
43
    case "${prev}" in
 
44
        --config|--decode|--restore)
 
45
            if [[ ${cur} != -* ]]; then
 
46
                _filedir
 
47
                return 0
 
48
            fi ;;
 
49
        --pw-cache)
 
50
             if [[ ${cur} != -* ]]; then
 
51
                COMPREPLY=( $(compgen -W "${pw_cache_commands}" -- ${cur}) )
 
52
                return 0
 
53
            fi ;;
 
54
        --remove|--remove-and-do-not-ask-again)
 
55
            if [[ ${cur} != -* ]]; then
 
56
                COMPREPLY=( $(compgen -W "$(_bit_snapshots_list)" -- ${cur}) )
 
57
                return 0
 
58
            fi
 
59
            ;;
 
60
        backintime*|${opts})
 
61
            if [[ ${cur} == -* ]] ; then
 
62
                COMPREPLY=( $(compgen -W "${opts} ${actions}" -- ${cur}) )
 
63
                return 0
 
64
            fi ;;
 
65
    esac
 
66
}
 
67
complete -F _backintime backintime
 
68
complete -F _backintime backintime-qt4
 
69