-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_unicode
More file actions
executable file
·57 lines (51 loc) · 1.04 KB
/
Copy pathsearch_unicode
File metadata and controls
executable file
·57 lines (51 loc) · 1.04 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
function help
{
cat <<EOH
For each term search unicode character where its definition contain the term.
Usage: $0 [-h] [-l] [-r] term1 term2
-h this help
-l large description
-r choose a random character
EOH
exit 1
}
UNICODEDATA="/usr/share/unicode/UnicodeData.txt"
[ -f "$UNICODEDATA" ] ||
{
echo "File $UNICODEDATA not found," >&2
echo "Install \"unicode-data\" (at least at Debian), and try again" >&2
exit 1
}
while getopts hlr opt;
do
case $opt in
h) help ;;
l) large=1 ;;
r) randomized=1 ;;
esac
done
shift $((OPTIND-1))
declare -A chars
for a in "$@"
do
chars[$a]="$(sed 's,;, ,g' $UNICODEDATA | awk -v c="$a" \
'BEGIN {IGNORECASE=1;} $0 ~ c {print $1;}' )"
if [ "$randomized" = 1 ]
then
chars[$a]="$(echo "${chars[$a]}" | sort -R | head -n 1)"
fi
done
for a in "$@"
do
for c in ${chars[$a]}
do
if [ "$large" = 1 ]
then
printf "\U$c $(grep "^$c;" $UNICODEDATA)\n"
else
printf "\U$c "
fi
done | sed 's, $,\n,'
done
# vim: tabstop=2 shiftwidth=2 expandtab