make_wordlist()
{
    cp -R stardict-GR-LingvoUniversal-2.4.2 /tmp/
    cd /tmp/stardict-GR-LingvoUniversal-2.4.2/
    mv GR-Universal.dict.dz GR-Universal.dict.gz
    gunzip GR-Universal.dict.gz
    /usr/lib/stardict-tools/stardict2txt GR-Universal.ifo ~/Langs/Deutsch/GR-Universal.txt
    cat ~/Langs/Deutsch/GR-Universal.txt | expand| sed 's/ *<.*//; s/ *$//' > ~/Langs/Deutsch/word-list.txt
}

if [ "$1" = init ]
then
    cd /usr/share/stardict/dic/
    make_wordlist
    exit 0
fi

TEMP=`mktemp /tmp/nw-shell-XXXXXX`
WORD_LIST=~/Langs/Deutsch/word-list.txt
rlwrap -f ${WORD_LIST} sh -c '
    while true; 
    do 
        printf "\033[01;33m > " ;
        read word options || { exit; printf "\033[00m" ; } ;
        if [ "$word" = grep ]
        then
            grep "$options" "'"${WORD_LIST}"'"
        elif [ "$word" = vf ]
        then
            verbformen "$options"
        elif [ "$word" = "#" ]
        then
            printf "\033[00mWelcome to session >>"$options"<<\n"  ;
            echo $word $options >> ~/Langs/Deutsch/de-shell.log
        else
            printf "\033[00m" ;
            echo $word >> ~/Langs/Deutsch/de-shell.log
            de $word; 
        fi
    done'
rm $TEMP