mlissner mlissner - 4 months ago 5x
Bash Question

psql ruins my shell if I press Ctrl+C

This is a bit of a weird one. If I start

but then press Ctrl+C when it prompts for a password, the program seems to exit, but I can't see what I type anymore even though I'm back in my shell. It's as if everything I type is getting hidden because it still thinks I'm typing my password.

The only solution for this that I've found is to start a new shell, which is fine, but not great. I'd love to understand what's happening here and how to fix it.


reset often works, but is not a panacea. For this case, only the terminal echo was disabled. Other programs may modify the handling of carriage return, making it awkward to type "reset" (you can do that, but would have to type controlJ to end the line).

In other cases, because reset relies upon the terminal description, it may not reset everything. Particular troublespots are (a) alternate character sets and (b) changes to the terminal's color palette.

  • While ncurses has many terminal descriptions which do reset the alternate character set, it is a common problem on Unix systems to not do this.
  • Over the past few years, people have been using the xterm 256color sequences to set a color palette, but reset has no way to revert those to a default palette.

Aside from the terminal description part, reset performs a function similar to stty sane.