1

I am using Konsole + ZSH in KDE with several tabs open. In some tabs I run different programs -- Python scripts with ipdb and other. At some point I cannot enter new line anymore -- pressing Enter just prints ^M.

I saw this answer and I think ipdb changes some of terminal settings which are not restored when I interrupt it pressing Ctrl+C or Ctrl+\:

$ stty -a
speed 38400 baud; rows 46; columns 180; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; 
swtch = <undef>; start = ^Q; stop = ^S; susp = <undef>; rprnt = ^R; werase = ^W;
lnext = <undef>; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff 
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

$ pip uninstall frozendict
Uninstalling frozendict:
...
Proceed (y/n)? ^M

Another terminal which works ok has these settings:

$ stty -a
speed 38400 baud; rows 46; columns 180; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; 
swtch = <undef>; start = ^Q; stop = ^S; susp = <undef>; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff 
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

So am thinking how to work around this.

I could somehow inject stty icrnl to be executed after a command was executed, but I would rather restore all settings not just icrnl. But reset is slow.

So my question is: how to execute something after a command was executed in ZSH and what to execute -- stty icrnl or reset? Or is there another solution?

Or is there a way to prohibit disabling icrnl flag?

1 Answer 1

3

This post was helpful, so I put this into .zshrc:

precmd()
{
    stty sane
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .