summaryrefslogtreecommitdiff
path: root/completions/screen
blob: 952d9766af810795272daf03bbb231a1c59952df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# bash completion for screen

have screen &&
_screen_sessions()
{
    COMPREPLY=( $( compgen -W "$( command screen -ls | sed -ne \
        's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p' )" \
        -- "$cur" ) )
} &&
_screen()
{
    local cur prev words cword

    COMPREPLY=()
    _get_comp_words_by_ref cur prev words cword

    if ((cword > 2)); then
        case ${words[cword-2]} in
            -[dD])
                _screen_sessions
                return 0
                ;;
        esac
    fi

    case $prev in
        -[rR])
            # list detached
            _screen_sessions 'Detached'
            return 0
            ;;
        -[dD])
            # list attached
            _screen_sessions 'Attached'
            return 0
            ;;
        -x)
            # list both
            _screen_sessions
            return 0
            ;;
        -s)
            _shells
            return 0
            ;;
        -c)
            _filedir
            return 0
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W '-a -A -c -d -D -e -f -fn -fa -h -i -ln \
            -list -L -m -O -p -q -r -R -s -S -t -U -v -wipe -x -X --help \
            --version' -- "$cur" ) )
    fi
} &&
complete -F _screen -o default screen

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh