Last active
June 18, 2023 00:52
-
-
Save maxkapur/399a0f4703c9268f39d6e0e439792b93 to your computer and use it in GitHub Desktop.
fzf wrapper
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
# 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