Skip to content

Instantly share code, notes, and snippets.

@peterldowns
Created March 30, 2023 15:01
Show Gist options
  • Save peterldowns/627d96039263a703d2dbbf9d5c7621ed to your computer and use it in GitHub Desktop.
Save peterldowns/627d96039263a703d2dbbf9d5c7621ed to your computer and use it in GitHub Desktop.
script to run a command and preview the results using fzf
#!/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