/
bazel.zsh
34 lines (30 loc) · 1.39 KB
/
bazel.zsh
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
_fzf_complete_bazel_test() {
_fzf_complete '-m' "$@" < <(command bazel query "kind('(test|test_suite) rule', //...)" 2> /dev/null)
}
_fzf_complete_bazel() {
local tokens
tokens=(${(z)LBUFFER})
if [ ${#tokens[@]} -ge 3 ] && [ "${tokens[2]}" = "test" ]; then
_fzf_complete_bazel_test "$@"
else
# Might be able to make this better someday, by listing all repositories
# that have been configured in a WORKSPACE.
# See https://stackoverflow.com/questions/46229831/ or just run
# bazel query //external:all
# This is the reason why things like @ruby_2_6//:ruby.tar.gz don't show up
# in the output: they're not a dep of anything in //..., but they are deps
# of @ruby_2_6//...
_fzf_complete '-m' "$@" < <(command bazel query --keep_going --noshow_progress "kind('(binary rule)|(generated file)', deps(//...))" 2> /dev/null)
fi
}
# See aliases in ~/.util/host.sh
_fzf_complete_sb() { _fzf_complete_bazel "$@" }
_fzf_complete_sbg() { _fzf_complete_bazel "$@" }
_fzf_complete_sbgo() { _fzf_complete_bazel "$@" }
_fzf_complete_sbo() { _fzf_complete_bazel "$@" }
_fzf_complete_sbr() { _fzf_complete_bazel "$@" }
_fzf_complete_sbl() { _fzf_complete_bazel "$@" }
_fzf_complete_st() { _fzf_complete_bazel_test "$@" }
_fzf_complete_sto() { _fzf_complete_bazel_test "$@" }
_fzf_complete_stg() { _fzf_complete_bazel_test "$@" }
_fzf_complete_stog() { _fzf_complete_bazel_test "$@" }