correct some indent, correct some bug
change how to detect tty prompt