Files
linux-bin/f

42 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-03-30 00:37:43 -07:00
#!/bin/bash
if [ "$1" == "-h" ] ; then
echo "
f - fuzzy preview and open text files or pdfs
usage:
f
f p
depends:
fzf
2021-10-19 01:38:43 -07:00
bat
2021-03-30 00:37:43 -07:00
grep, git-grep, or ripgrep
zathura (or other fast pdf viewer)
2021-10-19 01:38:43 -07:00
spdf.sh - handles saving to your bib db
2021-03-30 00:37:43 -07:00
"
exit 0
fi
set -e #exit if an error
if [ "$1" == "p" ]; then
ls *.pdf | fzf --preview 'pdftotext -l 2 -nopgbrk -q {1} -' \
--preview-window=up:70% --bind "enter:execute-silent(zathura {} &)" \
2021-05-04 19:23:54 -07:00
--bind "ctrl-s:execute(spdf.sh {})+reload(ls *.pdf)"
2021-03-30 00:37:43 -07:00
exit 1
fi
if [ -z "$1" ]; then
#FZF_DEFAULT_COMMAND=rg -i --files --glob "!.git/*"
2021-04-08 20:52:17 -07:00
# fzf --delimiter : --preview 'less {1}' \
fzf --delimiter : --preview 'bat --color=always --style=numbers --line-range=:500 {}' \
2021-03-30 00:37:43 -07:00
--preview-window=up:70% --bind "enter:execute-silent(gvim {1} &)"
else
2021-04-08 20:52:17 -07:00
# rg $1 | fzf --delimiter : --preview 'less {1}' \
2021-10-19 01:38:43 -07:00
# todo: replace this with a series elif blocks mapping selective previews and downstream application bindings to a set of desired filetypes
ls *.$1 | fzf --delimiter : --preview 'bat --color=always --style=numbers --line-range=:500 {}' \
2021-03-30 00:37:43 -07:00
--preview-window=up:70% --bind "enter:execute-silent(gvim {1} &)"
fi
2021-10-19 01:38:43 -07:00