Help and docs
Sign in

grindlemire/dotfiles code browser

main 0375daa
38 lines · 962 B
 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
#compdef c godir repos

# Tab completion for c, godir and repos: repo names under ~/code, each shown
# with its bucket (gitstack -- alethi). repos also completes bucket/ filters
# and its flags.

_code_repos() {
    local root=$HOME/code d
    local -a repos buckets
    for d in $root/*/*(/N); do
        repos+=("${d:t}:${${d:h}:t}")
    done
    _describe -t repos 'repo' repos
    if [[ $service == repos ]]; then
        for d in $root/*(/N); do
            buckets+=("${d:t}/:bucket")
        done
        _describe -t buckets 'bucket' buckets
    fi
}

_c() {
    case $service in
        repos)
            _arguments \
                '-p[only repos with a problem]' \
                '-f[fetch every repo first]' \
                '-g[include -github fallback clones]' \
                '-h[show help and what each flag means]' \
                '1:repo:_code_repos'
            ;;
        *)
            _code_repos
            ;;
    esac
}

_c "$@"