-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkamp-fifo
More file actions
executable file
·43 lines (35 loc) · 790 Bytes
/
kamp-fifo
File metadata and controls
executable file
·43 lines (35 loc) · 790 Bytes
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
#!/bin/sh
#
# pipe stdin into fifo buffer
#
# Example: make | kamp-fifo
set -euf
usage() {
printf "Usage: %s: [-c client] [fifo_buffer_name]\n" "$(basename "$0")" >&2
exit 2
}
cflag=
while getopts hc: OPTION; do
case "$OPTION" in
c)
cflag=1
cval="$OPTARG"
;;
h|?)
usage
;;
esac
done
shift $((OPTIND - 1))
kamp >/dev/null # fail early if there is no session
d=$(mktemp -d)
fifo="$d/fifo"
mkfifo "$fifo"
trap 'unlink "$fifo" && rmdir "$d"; exit' EXIT HUP INT TERM
if [ "$cflag" ]; then
kamp -c "$cval" send edit -scroll -fifo "$fifo" "*${1:-kamp-fifo}*" \; focus
else
kamp ctx -c >/dev/null # fail early if there is no client
kamp send edit -scroll -fifo "$fifo" "*${1:-kamp-fifo}*" \; focus
fi
cat >"$fifo"