Based on liudr phi_prompt: http://liudr.wordpress.com/libraries/phi_prompt/