Skip to content

linse/anki-prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#anki-prompt flashcards in the bash prompt

the prompt

Contents:

The character frequency list is from http://www.zein.se/patrick/3000char.html and I saved it without tags to pagetext.txt.

Edit the user configurable parameters at the top of the script (it won't run otherwise), then put the following in your .bashrc and/or .bash_profile (or other shell rc). In fact you only need the HANZI part, but I also have a symbol colored red or green, depending on the exit status of the last command.

function exitstatus {

	EXITSTATUS="$?"
	BOLD="\[\e[1m\]"
	RED="\[\e[1;31m\]"
	MAGENTA="\[\e[35;1m\]"
	BLUE="\[\e[34;1m\]"
	GREEN="\e[0;32m\]"
	OFF="\[\e[m\]"

	HANZI=`<full path to the script>/anki-prompt/prompt.pl`

	if [ "$EXITSTATUS" -eq "0" ]
		then
			PS1="${HANZI}${BOLD}${MAGENTA}\u${OFF} ${BLUE}\w${OFF} ${GREEN}${OFF} "
	else
		PS1="${HANZI}${BOLD}${MAGENTA}\u${OFF} ${BLUE}\w${OFF} ${RED}${OFF} "
	fi

	PS2="${BOLD}>${OFF} "

}

PROMPT_COMMAND=exitstatus

prerequisites

The script uses Color::Output which is not packed in Debian systems. It incldues a fall-back to use Term::ANSIColor which is part of the standard perl modules.

On Linux system you might need to change the exitstatus function PS1 to include a \n:

                        PS1="${HANZI}\n${BOLD}${MAGENTA}\u${OFF} ${BLUE}\w${OFF} ${GREEN}${OFF} "

About

flashcards in the bash prompt

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages