Last active
September 13, 2021 09:33
-
-
Save reiyw/3c50f44ef8fa872cdbec309466554d04 to your computer and use it in GitHub Desktop.
fzf keybind to specify a target for Bazel run in zsh.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
bindkey '<keymap>' fzf-bazel-run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment