summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-12-06 01:31:57 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-12-06 01:31:57 +0100
commit873165b6d8cf817e6f581be489c4aa7deea9b421 (patch)
tree5139657ee0a102049bea3af85116dbf4afe5b28c /.local
parent02e4686ccd7c95c6df855be61496c75c92b11396 (diff)
uni: Switch from sh to andy
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/uni47
1 files changed, 25 insertions, 22 deletions
diff --git a/.local/bin/uni b/.local/bin/uni
index 778d2eb..a829fd0 100755
--- a/.local/bin/uni
+++ b/.local/bin/uni
@@ -1,34 +1,37 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-set -e
+set -e NOTIFY_LONG unicode
+set -e NOTIFY_SHORT uni
-export NOTIFY_LONG=unicode
-export NOTIFY_SHORT="${0##*/}"
-
-setup()
-{
- curl 'https://www.unicode.org/Public/UNIDATA/UnicodeData.txt' \
- | sed -E '
+func setup {
+ curl 'https://www.unicode.org/Public/UNIDATA/UnicodeData.txt'
+ | sed -E r#'
s/;[^;]*//2g
s/\<(.)([A-Z]*)/\1\L\2/2g
/^[^;]*;</d
/Compatibility/d
/Variation Selector/d
s/[^;]*/\\u&/
- ' >"$DATA"
+ s/^\\u([^;]{5})/\\U000\1/
+ '# >$DATA
}
-readonly DATA="${XDG_DATA_HOME:-$HOME/.local/share}/unicode-data"
-[ -f "$DATA" ] || setup
+test $#XDG_DATA_HOME -eq 0 && set XDG_DATA_HOME $HOME/.local/share
+set DATA $XDG_DATA_HOME/unicode-data
+test -f $DATA || setup
+
+set idx `{
+ tee >{cut -d';' -f1 | read -d\n runes} <$DATA
+ | cut -d';' -f2 $DATA
+ | osel -i
+}
+set rune `printf $runes[$idx]
-idx="$(cut -d';' -f2 "$DATA" | osel -i)"
-code="$(head -n "$idx" "$DATA" | tail -n1 | cut -d';' -f1)"
-rune="$(printf $code)"
+if test -t 2 {
+ wl-copy -n "$rune"
+ | notify 'Rune Copied' "The rune ‘$rune’ was copied to the clipboard"
+} else {
+ wtype -- $rune
+}
-if [ -t 2 ]
-then
- wl-copy -n "$rune" \
- && notify 'Rune Copied' "The rune ‘$rune’ was copied to the clipboard"
-else
- wtype -- "$rune"
-fi
+# vi: ft=sh