-
Notifications
You must be signed in to change notification settings - Fork 1
/
54ysh.sh
executable file
·82 lines (70 loc) · 1.48 KB
/
54ysh.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# 54ysh -- a shell-like speaking tool for mac
#
# copyright (c) 2018 Cj-bc
#
# This software is released under MIT License.
# http://opensource.org/license/mit-license.php
type say >/dev/null 2>&1
say_found=$?
function say_impl() {
if [ $say_found -eq 0 ]; then
say $@
else
./say_wrapper.sh $@
fi
}
if [ -p /dev/stdin ]
then
temp=$(mktemp /tmp/54ysh.stdin.tmp.XXXXXX)
cat - > $temp
# push stdin to stdout
if [ -p /dev/stdout ]
then
cat $temp
fi
while read userInput
do
if [ "$(echo "$userInput" | nkf -g)" = "ASCII" ]
then
say_impl -v alex "$userInput"
else
say_impl -v kyoko "$userInput"
fi
input=("${input[@]}" "$userInput")
done < $temp
rm $temp
exit 0
fi
# Logo and info
cat <<EOT
======= === ====== ==
== = == == ==
== = == == == ==
======= = == ===== == = ==
== ========= = == == === ==
== == = == == == ==
======= == ==== ===== == ==
==
==
== by Cj-bc
speaking tool for mac. ver.0.0.1
Type here
EOT
echo -n "> "
read userInput
echo -n "> "
while [ "$userInput" != ":q" ]
do
if [ "$(echo $userInput | nkf -g)" = "ASCII" ]
then
say_impl -v alex $userInput
else
say_impl -v kyoko $userInput
fi
read userInput
echo -n "> "
done
echo "finished correctly"
return 0