-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfurlview
executable file
·55 lines (47 loc) · 1 KB
/
furlview
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
51
52
53
54
55
#!/usr/bin/env bash
#
# Simple replacement for urlview using fzf in X.
#
# Usage:
#
# $ furlview FILE1 ... FILEn
# $ foo | furlview
# $ furlview < FILE
# $ furlview <<< "foo"
# $ furlview <<URIS
## foo
## URIS
#
# FILE is regular or piped, that is also <(foo)
command -- test-xorg ||
exit 1
function __select {
exec -- grep-url |
exec -- fzf --tac -e -i -m
}
function __is_file [[ -p $1 || -f $1 ]]
if __is_file /dev/stdin; then
mapfile -t furls < <(__select)
else
if ! (($#)); then
echo Error: Missing arguments 1>&2
exit 1
fi
mapfile -t furls < <(
for f in "$@"; do
if __is_file "$f"; then
command -- cat -- "$f"
else
printf \
"Error: File '%s' is neather a regular file nor a named pipe\n" \
"$f" 1>&2
fi
done |
__select
)
fi
for u in "${furls[@]}"; do
command -- daemonize run-chromium "$u" &
done
wait
# vim: set ft=zsh :