Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 111 lines (77 sloc) 2.97 KB
#!/bin/fish
#
# lrnkata - Learn katakana 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 kata kata_k kata_s kata_t
## 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 kata ア イ ウ エ オ ン
set roma a i u e o n
set kata_k カ キ ク ケ コ
set roma_k ka ki ku ke ko
set kata_s サ シ ス セ ソ
set roma_s sa shi su se so
set kata_t タ チ ツ テ ト
set roma_t ta chi tsu te to
set kata_n ナ ニ ヌ ネ ノ
set roma_n na ni nu ne no
set kata_h ハ ヒ フ ヘ ホ
set roma_h ha hi fu he ho
set kata_m マ ミ ム メ モ
set roma_m ma mi mu me mo
set kata_y ヤ ユ ヨ
set roma_y ya yu yo
set kata_r ラ リ ル レ ロ
set roma_r ra ri ru re ro
set kata_w ワ ヲ
set roma_w wa o
set kata_g ガ ギ グ ゲ ゴ
set roma_g ga gi gu ge go
set kata_z ザ ジ ズ ゼ ゾ
set roma_z za ji zu ze zo
set kata_d ダ ヂ ヅ デ ド
set roma_d da ji zu de do
set kata_b バ ビ ブ ベ ボ
set roma_b ba bi bu be bo
set kata_p パ ピ プ ペ ポ
set roma_p pa pi pu pe po
## FUNCTIONS
# This function gets a random katakana and it's answer
function randomkata
set random (seq (count $$learn) | shuf -n 1)
set learnroma (string replace 'kata' '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
randomkata
while true
set random (seq (count $$learn) | shuf -n 1)
set learnroma (echo $learn | sed "s/kata/roma/g" | tr \ \n)
set -g question (echo $$learn | cut -d \ -f $random)
set -g answer (echo $$learnroma | cut -d \ -f $random)
read -p 'echo "What is the romaji equivalent 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
randomkata
else
if test $repeat = false
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.