summaryrefslogtreecommitdiff
path: root/khal-list
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-11-03 19:51:42 +0100
committerErich Eckner <git@eckner.net>2021-11-03 19:51:42 +0100
commit8945e431c7b0c64dd4b1d508449943ba06f054a5 (patch)
tree1b2386fcb715a4aab59a7bd32986ba9610c4a98b /khal-list
parent4630a8bffe88f0cb52d4b56dd417383f7e0f19da (diff)
downloadkhal-extras-8945e431c7b0c64dd4b1d508449943ba06f054a5.tar.xz
use tmp_dir, show ellipsis of error
Diffstat (limited to 'khal-list')
-rwxr-xr-xkhal-list27
1 files changed, 25 insertions, 2 deletions
diff --git a/khal-list b/khal-list
index d662ba2..d4cdd47 100755
--- a/khal-list
+++ b/khal-list
@@ -2,14 +2,19 @@
date_format='%F %H:%M'
+tmp_dir=$(mktemp -d)
+trap 'rm -rf --one-file-system "${tmp_dir:?}"' EXIT
+
script -qefc '/usr/bin/khal list '"$(
date +"${date_format}"
)"' '"$(
date +"${date_format}" -d@$((
$(date +%s)+6*24*60*60
))
-)" /dev/null </dev/null \
-| /usr/src/skripte/ansi-color-to-conky-color/ansi-color-to-conky-color "$@" \
+)"' 2>'"${tmp_dir}"'/stderr >'"${tmp_dir}"'/stdout' /dev/null </dev/null
+
+/usr/src/skripte/ansi-color-to-conky-color/ansi-color-to-conky-color "$@" \
+< "${tmp_dir}/stdout" \
| sed '
s@\xe2\x9f\xb3@@g
s@\r$@@
@@ -26,3 +31,21 @@ script -qefc '/usr/bin/khal list '"$(
| sed '
s/\(\(^\|}\)[^{}]\{47\}\)[^{}]\+\${/\1...${/
'
+
+sed '
+ s@^\(.\{47\}\)....*$@\1...@
+ s@#@\\#@g
+' "${tmp_dir}/stderr" \
+| tac \
+| sed -n '
+ $ {
+ p
+ d
+ }
+ 1,3 p
+' \
+| tac \
+| sed '
+ 1 s@^@${color red}@
+ $ s@$@${color}@
+'