blob: 4be2d86e046ae47fc1d8e2eb578e1720d66a0d52 (
plain) (
blame)
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
|
#!/bin/sh
set -e
setup()
{
curl 'https://www.unicode.org/Public/UNIDATA/UnicodeData.txt' \
| >"$DATA" sed -E \
-e 's/;[^;]*//2g' \
-e 's/\<(.)([A-Z]*)/\1\L\2/2g' \
-e '/^[^;]*;</d' \
-e '/Compatibility/d' \
-e '/Variation Selector/d'
}
readonly DATA="${XDG_DATA_HOME:-$HOME/.local/share}/unicode-data"
[ -f "$DATA" ] || setup
opt="$(cut -d';' -f2 "$DATA" | osel)"
rune="$(
awk -vopt="$opt" -F';' \
'$2 == opt { printf "\\\\u%s\\\\n", $1; exit }' "$DATA" \
| xargs printf
)"
wl-copy -n "$rune" && notify uni unicode 'Rune Copied' \
"The rune ‘$rune’ was copied to the clipboard"
|