Skip to content

Instantly share code, notes, and snippets.

@reiyw
reiyw / fzf-bazel-run.zsh
Last active September 13, 2021 09:33
fzf keybind to specify a target for Bazel run in zsh.
fzf-bazel-run() {
local ret=$(bazel query 'kind("_binary", //...)' --output location | fzf --with-nth 4 --preview 'a=($(echo {} | tr ":" " ")); tail -n +$a[2] $a[1] | sed "/^$/q"')
local a=(${(s/ /)ret})
local target=$a[4]
if [[ -n "$target" ]]; then
BUFFER="bazel run $target"
CURSOR=${#BUFFER}
fi
}
zle -N fzf-bazel-run