Last active
April 8, 2022 16:31
-
-
Save suvayu/d6e0a5da746ea27ac770c7b744fac337 to your computer and use it in GitHub Desktop.
Preview list of files
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
#!/bin/bash | |
# License: GPLv2 | |
# set -o xtrace | |
if [[ -t 0 ]]; then | |
echo no stdin | |
exit 1 | |
elif [[ ! -f $(which fzf 2> /dev/null) ]]; then | |
less | |
exit | |
fi | |
declare FILES=$(cat /dev/stdin) | |
# declare PAGER=$(which bat 2> /dev/null || echo less) | |
declare SELECTION | |
while true; do | |
SELECTION=$( | |
echo "${FILES}" | \ | |
fzf --height 25 -0 -1 --disabled -e \ | |
--bind 'q:abort,/:toggle-search' \ | |
--preview="less {}" \ | |
--preview-window=right:60% "${@}") | |
[[ -n $SELECTION ]] && less -N $SELECTION || break | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment