Skip to content

Instantly share code, notes, and snippets.

@maxkapur
Last active June 18, 2023 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxkapur/399a0f4703c9268f39d6e0e439792b93 to your computer and use it in GitHub Desktop.
Save maxkapur/399a0f4703c9268f39d6e0e439792b93 to your computer and use it in GitHub Desktop.
fzf wrapper
# Just a couple of light tweaks to the examples listed in the `fzf` readme:
# https://github.com/junegunn/fzf#preview-window
# Save this file to:
# ~/.config/fish/functions/fzl.fish
function fzl
# `bat` is aliased to `batcat` on Debian
if type -q batcat
set -f bat_command "batcat"
else
set -f bat_command "bat"
end
# Set the overall width of the `bat` preview to
# 50% the width of the current terminal
set -l bat_width $(math ceil $COLUMNS x 0.5)
# My preferred `bat` options
set -f bat_command \
$bat_command \
--style numbers \
--color always \
--italic-text always \
--wrap auto \
--terminal-width $bat_width
fzf \
--preview "$bat_command {}" \
--preview-window right,$bat_width,nowrap
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment