oh-my-zsh/plugins/hirakata/hirakata.plugin.zsh

34 lines
796 B
Bash
Raw Normal View History

2014-06-07 20:06:24 +00:00
p="$ZSH/plugins/hirakata/"
fh=$(cat $p"files/hira.txt")
fk=$(cat $p"files/kata.txt")
function hirakata() {
random_symbol=$(echo "$fh\n$fk" | shuf -n1)
romaji=0
for arg in "$@"
do
case "$arg" in
"romaji")
romaji=1
;;
"hiragana")
random_symbol=$(echo "$fh" | shuf -n1)
;;
"katakana")
random_symbol=$(echo "$fk" | shuf -n1)
;;
esac
done
symbol=$(echo $random_symbol | cut -d ' ' -f1)
sound=$(echo $random_symbol | cut -d ' ' -f2)
2014-06-07 20:06:24 +00:00
(mpg321 -q $p/sounds/$sound & ) > /dev/null 2>&1
echo -n $symbol
if [ $romaji -eq 1 ]; then
romaji=$(echo $sound | cut -d '.' -f1)
echo -n " ($romaji)"
fi
}