Created
August 29, 2023 11:35
-
-
Save CognitiveDisson/33582597325218712bafbe404f46d5c6 to your computer and use it in GitHub Desktop.
Revisions
-
CognitiveDisson created this gist
Aug 29, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ # Example: vim (bzqfzf //...) # Description: ZSH functions (should be easily converted to zsh) for Basel fuzzy search. # Requirements: # bazel # brew install fzf # brew install bat # Add "source ~/.zsh_functions/bzqfzf.sh" to `~/.zshrc` # ~.zsh_functions/bzqfzf.sh: function bat_preview_for_bazel() { bazel_target="$argv[1]" bazel_output=$(bazel query $bazel_target --noshow_progress --output=build | head -1 | sed -e "s/^#[[:space:]]//") bazel_file=$(echo "$bazel_output" | cut -d: -f1) line=$(echo "$bazel_output" | cut -d: -f2) bat --style=numbers --color=always --line-range $line: "$bazel_file" } function bazel_file_from_target() { bazel_target="$argv[1]" bazel_output=$(bazel query $bazel_target --noshow_progress --output=build | head -1 | sed -e "s/^#[[:space:]]//") bazel_file=$(echo "$bazel_output" | cut -d: -f1) echo "$bazel_file" } function bzqfzf() { bazel query $argv | fzf --preview='bat_preview_for_bazel {}' --bind 'enter:become(bazel_file_from_target {})' }