Hacker News new | ask | show | jobs
by polygot 3094 days ago
On the lines of "just working", it'd be cool to have a shell which if I could accidentally cat a binary file and not have the shell be completely in-operable or have to run this long archaic command to get it working again.

Maybe have something like "when I run the cat command, ignore all commands to the terminal until cat finishes".

3 comments

Two errors there.

1. "reset" is six keypresses long, seven if you use the Control+J approach (although terminal control codes do not affect the line discipline and won't by themselves upset the newline settings of the line discipline in the first place), and not really archaic or long. On many terminal emulators, there is a menu option on the emulator that does the very same thing.

2. The mosh people addressed this problem years ago, and made a lot of noise about doing so. It's mainly a matter of just not supporting the old ISO/IEC 2022 control sequences for changing 7-bit character sets. See https://news.ycombinator.com/item?id=13904008 for more.

Our draft already contains a command for "set terminal into ignore-escape-sequences mode". I added that last week when someone showed how to hide malicious code in "git diff" by using specifically crafted control sequences.
What long archaic command are you running? 'clear; reset' usually does it for me.
Sometimes clear; reset works but other times I can't see what I'm typing, and so when I type it and hit enter it might clear the screen, sometimes it runs the command but the bash prompt is completely messed up. I use tmux a lot, so I usually use the reset code from this answer: https://unix.stackexchange.com/questions/49886/tmux-status-b...

stty sane; printf '\033k%s\033\\\033]2;%s\007' "`basename "$SHELL"`" "`uname -n`"; tput reset; tmux refresh