darkrc/bin/unicode

17 lines
632 B
Bash
Executable file

#!/bin/sh
alias dmenu="$HOME/darkrc/bin/dmenu-themed"
namelist=$HOME/.local/unicode/NamesList.txt
if [ ! -f "$namelist" ]
then
echo $namelist not found, downloading...
mkdir -p $(dirname "$namelist")
touch "$namelist"
curl 'https://www.unicode.org/Public/UCD/latest/ucd/NamesList.txt' \
| sed -n -e '/<.*>/d' -e '/^[0-9A-F]\+/p' \
| cp2utf8 > "$namelist" || exit
fi
codepoint=$(cat "$namelist" | sed -e 's/\t/ /g' | dmenu -p "Unicode: " -i -l 20 | awk '{print $1}' | grep '^[0-9A-F]\+')
if [ -z "$codepoint" ];
then echo No codepoint selected >&2; exit
fi
printf '\\\\U%8s\n' $codepoint | sed 's/ /0/g' | xargs printf