Created
March 30, 2023 15:01
-
-
Save peterldowns/627d96039263a703d2dbbf9d5c7621ed to your computer and use it in GitHub Desktop.
script to run a command and preview the results using fzf
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 characters
#!/usr/bin/env zsh | |
# Opens the FZF preview in full-screen mode, and re-runs a command with any | |
# given arguments while allowing paging. | |
# | |
# Arguments: | |
# $1 = command to preview. | |
# | |
# Example: | |
# preview nix-search | |
# | |
# Notes: | |
# - **Only** use this with commands that are non-destructive. | |
# - Won't run the command until you give it some input. | |
# | |
FZF_DEFAULT_COMMAND='echo ""' \ | |
fzf \ | |
--phony \ | |
--disabled \ | |
--print-query \ | |
--preview "echo {q} | xargs $1" \ | |
--preview-window=down,wrap,99% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment