Skip to content
Find file
d10a247
executable file 115 lines (80 sloc) 3.39 KB
#!/bin/fish
#
# lrnhira - Learn hiragana in the terminal.
# onodera, https://github.com/onodera-punpun
## CONFIGURATION
# The hiragana you want to learn, check DEFINE below for var names
# Enter var's twice or more to make them more common
set learn hira hira_k hira_s hira_t hira_n hira_h hira_m hira_words
## DEFINE
set yay 'Yay' 'Well done' 'Keep it up' 'Very good' 'Kabam' 'Killing it' 'Not bad' 'Nice going' 'Good job' 'Perfect' 'Amazing' 'Wowzers' 'You CAN even' 'C-C-C-COMBO BREAKER' 'That\'s the spirit' 'Excellent' 'Niiiiice' 'Noice' 'Yatta' 'Sugoi'
set nay 'Nay' 'Wrong again' 'WROOOONG' 'That\'s SO wrong' 'FUCK YOU' 'You can do better' 'Please' 'You disgust me' 'Kill yourself' 'You suck' 'Failure' 'Just keep trying' 'You\'re a dissapointment' 'You should have been swallowed' 'Zipperhead' 'What the fuck man'
set hira あ い う え お ん
set roma a i u e o n
set hira_k か き く け こ
set roma_k ka ki ku ke ko
set hira_s さ し す せ そ
set roma_s sa shi su se so
set hira_t た ち つ て と
set roma_t ta chi tsu te to
set hira_n な に ぬ ね の
set roma_n na ni nu ne no
set hira_h は ひ ふ へ ほ
set roma_h ha hi fu he ho
set hira_m ま み む め も
set roma_m ma mi mu me mo
set hira_y や ゆ よ
set roma_y ya yu yo
set hira_r ら り る れ ろ
set roma_r ra ri ru re ro
set hira_w わ を
set roma_w wa o
set hira_g が ぎ ぐ げ ご
set roma_g ga gi gu ge go
set hira_z ざ じ ず ぜ ぞ
set roma_z za ji zu ze zo
set hira_d だ ぢ づ で ど
set roma_d da ji zu de do
set hira_b ば び ぶ べ ぼ
set roma_b ba bi bu be bo
set hira_p ぱ ぴ ぷ ぺ ぽ
set roma_p pa pi pu pe po
set hira_words わたし ぼく かれ かのじょ あなた これ ここ この それ そこ その ひと いぬ ねこ いえ ありがとう どういたしまして おはよう こんにちは こんばんは さよなら あい
set roma_words watashi boku kare kanojo anata kore koko kono sore soko sono hito inu neko ie arigatou douitashimashite ohayou konnichiwa konbanwa sayonara ai
## FUNCTIONS
# This function gets a random hiragana and it's answer
function randomhira
set random (seq (count $$learn) | shuf -n 1)
set learnroma (string replace -r 'hira' 'roma' $learn | string split ' ')
set -g question (echo $$learn | cut -d \ -f $random)
set -g answer (echo $$learnroma | cut -d \ -f $random)
end
## EXECUTE
set correct 0
set incorrect 0
set repeat false
# Add mistakes to learn array
set learn $learn hira_mistakes
randomhira
while true
read -p 'echo "What is the romaji of "(set_color yellow)"$question"(set_color normal)"? "' input
clear
if test $input = $answer
if test $repeat = false
set correct (math $correct + 1)
end
echo -e (echo $yay[(seq (count $yay) | shuf -n 1)])"! ("(set_color green)"$correct"(set_color normal)" correct, "(set_color red)"$incorrect"(set_color normal)" incorrect)\n"
set repeat false
randomhira
else
if test $repeat = false
# Make this mistake more commonly occur
set hira_mistakes $hira_mistakes $question $question $question
set roma_mistakes $roma_mistakes $answer $answer $answer
set incorrect (math $incorrect + 1)
end
echo -e (echo $nay[(seq (count $nay) | shuf -n 1)])"! The correct answer is "(set_color yellow)"$answer"(set_color normal)"! ("(set_color green)"$correct"(set_color normal)" correct, "(set_color red)"$incorrect"(set_color normal)" incorrect)\n"
set repeat true
sleep 1
end
end
Something went wrong with that request. Please try again.