brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Ctrl-S freezes the terminal, Ctrl-Q wakes it up again

Terminal
~/tips/tip-terminal-ctrl-s-freeze-ixon

stty -ixon

Explains why the terminal stops responding after Ctrl-S and how to stop that for good.

You press Ctrl-S out of habit, because that saves a file everywhere else, and the terminal stops reacting. Nothing you type shows up. It looks like a hang, but the terminal is only paused.

Ctrl-S is the old XOFF flow control key. It tells the terminal to stop sending output, and everything you type after that waits in a queue. Press Ctrl-Q (XON) and the screen catches up with everything at once.

I would rather not have the trap at all, so I’d turn flow control off in the shell startup file:

stty -ixon

Put that line in ~/.zshrc or ~/.bashrc. You can check the result with stty -a: it now lists -ixon instead of ixon. A bonus in bash is that Ctrl-S becomes free for forward history search, the partner of Ctrl-R that you never got to use.

stty -a | grep -o -- '-*ixon'

Only run stty in interactive shells. In a script or a non-interactive ssh command there is no terminal, and you get an error like stty: stdin isn't a terminal. Wrapping it in [[ $- == *i* ]] && stty -ixon keeps it quiet. If someone else’s machine freezes on you, remember Ctrl-Q before you reach for the close button.

Further reading: stty (POSIX specification), stty man page (macOS)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link