-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit-client
executable file
·43 lines (38 loc) · 881 Bytes
/
edit-client
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
#!/usr/bin/env bash
set -e
9 9p read plumb/edit |while true; do
read -r src
read -r dst
read -r wdir
read -r type
read -r attrs
read -r ndata
LC_ALL=C read -rN $ndata data
client='%opt{jumpclient}'
evaluate=""
session=""
eval set -- "$attrs"
while [[ $# -ne 0 ]]; do
case "$1" in
client=*) client="${1#client=}";;
evaluate=*) evaluate="${1#evaluate=}";;
session=*) session="${1#session=}";;
esac
shift
done
dataFile=$(mktemp)
printf %s "$data" >"$dataFile"
printf '
evaluate-commands -try-client %s %%{
try %%{
set-option window plumb_data %%file{%s}
nop %%sh{rm -f "%s"}
%s
try focus
} catch %%{
echo -markup "{Error}%%val{error}"
echo -debug "%%val{error}"
}
}
' "$client" "$dataFile" "$dataFile" "$evaluate" |kak -p "$session"
done