-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf
executable file
·51 lines (40 loc) · 1.67 KB
/
f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
if [ "$1" == "-h" ] ; then
echo "
f - fuzzy preview and open text files or pdfs
usage:
f
f p #then type <enter> to preview
f p #then type <ctrl-s> to save pdf with spdf.sh
depends:
fzf
bat
grep, git-grep, or ripgrep
zathura (or other fast pdf viewer)
spdf.sh - handles saving to your bib db
"
exit 0
fi
set -e #exit if an error
#todo: simplify.
if [ "$1" == "p" ]; then
ls *.pdf | fzf --preview 'pdftotext -l 2 -nopgbrk -q {1} -' \
--preview-window=up:70% --bind "enter:execute-silent(zathura {} &)" \
--bind "ctrl-s:execute(spdf.sh {})+reload(ls *.pdf)"
exit 1
fi
if [ -z "$1" ]; then
#FZF_DEFAULT_COMMAND=rg -i --files --glob "!.git/*"
fzf --delimiter : --preview 'bat --color always --style=numbers --line-range=:500 {1}' \
--preview-window=up:70% --bind "enter:execute(xdg-open {1})"
# --preview-window=up:70% --bind "enter:execute($VISUAL {1})"
# fzf --delimiter : --preview 'bat --color=always --style=numbers --line-range=:500 {}' \
# --preview-window=up:70% --bind "enter:execute-silent(gvim {1} &)"
else
# rg $1 | fzf --delimiter : --preview 'less {1}' \
# todo: replace this with a series elif blocks mapping selective previews and downstream application bindings to a set of desired filetypes
#use xdg-mime, filetype info for opening
ls *$1 | fzf --delimiter : --preview 'bat --color always --style=numbers --line-range=:500 {1}' \
--preview-window=up:70% --bind "enter:execute(xdg-open {1})"
# --preview-window=up:70% --bind "enter:execute-silent(gvim {1} &)"
fi