aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/mex.bash
blob: bc3d2c7b651fc4ff8f8aeac54374ce0c994d888e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Completion setup for mex(1df), completing non-executable files in $PATH
_mex() {
    local -a path
    IFS=: read -ra path < <(printf '%s\n' "$PATH")
    local dir name
    for dir in "${path[@]}" ; do
        [[ -d $dir ]] || continue
        for name in "$dir"/* ; do
            [[ -e $name ]] || continue
            ! [[ -d $name ]] || continue
            ! [[ -x $name ]] || continue
            COMPREPLY[${#COMPREPLY[@]}]=${name##*/}
        done
    done
}
complete -F _mex mex