aboutsummaryrefslogtreecommitdiff
path: root/scripts/bash_completion/pdextended
blob: ba9404910e85030c622105a05d9a842b5bf06a37 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# 
# bash_completion file for Pd-extended
# 
# Save as: /etc/bash_completion.d/pd-extended or ~/.bash_completion and enjoy
# never having to type any full command line option anymore. Instead you can
# press <TAB>.
#
# If you want to help, these are fine introductions to bash's completion
# feature:
# 
# http://www.debian-administration.org/articles/316
# http://www.debian-administration.org/articles/317
#
# First version written by Frank Barknecht <fbar AT footils.org> Dec 26 2005
# customized for Pd-extended by Hans-Christoph Steiner <hans@eds.org> 2012-10-17

function _pdextended() 
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    
    # Pd-extended's options:
    opts="\
    -32bit \
    -alsa \
    -alsaadd \
    -alsamidi \
    -audiobuf \
    -audiodev \
    -audioindev \
    -audiooutdev \
    -batch \
    -blocksize \
    -channels \
    -d \
    -extraflags \
    -font-face \
    -font-size \
    -font-weight \
    -guicmd \
    -guiport \
    -help \
    -helppath \
    -inchannels \
    -jack \
    -lib \
    -listdev \
    -mididev \
    -midiindev \
    -midioutdev \
    -noadc \
    -noaudio \
    -noautopatch \
    -nodac \
    -nogui \
    -noloadbang \
    -nomidi \
    -nomidiin \
    -nomidiout \
    -noprefs \
    -nosleep \
    -nostartup \
    -nostdpath \
    -nrt \
    -open \
    -oss \
    -outchannels \
    -path \
    -r \
    -realtime \
    -rt \
    -schedlib \
    -send \
    -sleepgrain \
    -stderr \
    -stdpath \
    -verbose \
    -version"

    # options that require an argument:
    case "${prev}" in
        # directory argument:
        # TODO: colon-separated paths as in "/usr/lib/pd/extra:/home/user/pd"
        -path)
            COMPREPLY=( $(compgen -d ${cur}) )
            return 0
            ;;
        -stdpath)
            COMPREPLY=( $(compgen -d ${cur}) )
            return 0
            ;;
        -helppath)
            COMPREPLY=( $(compgen -d ${cur}) )
            return 0
            ;;
        # patch file argument:
        -open)
            _filedir '@(pd|pat|mxt|mxb)'
            return 0
            ;;
        # other
        -d)
            COMPREPLY=( $(compgen -W "0 1 2 3" -- ${cur}) )
            return 0
            ;;
        *)
            ;;
    esac

    if [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    else
        _filedir '@(pd|pat|mxt|mxb)'
    fi
}
complete -o default -F _pdextended pd-extended
complete -o default -F _pdextended pdextended