Comment by larsbrinkhoff

6 months ago

Just type Control-U once.

The Just in that sentence is wholly unjustified. There are plenty of cli/tui/console/shell shortcuts that are incredibly useful, yet they are wholly undiscoverable and do not work cross-platform, e.g. shell motions between macOS and reasonable OSes.

  • > shell motions between macOS and reasonable OSes

    All the movement commands I know work the same in the terminal on a default install of macOS as it does in the terminal on various Linux distros I use.

    Ctrl+A to go to beginning of line

    Ctrl+E to go to end of line

    Esc, B to jump cursor one word backwards

    Esc, F to jump cursor one word forward

    Ctrl+W to delete backwards until beginning of word

    And so on

    Both in current versions of macOS where zsh is the default shell, and in older versions of macOS where bash was the default shell.

    Am I misunderstanding what you are referring to by shell motions?

  • The number of times I’ve attempted to use Ctrl-U in a Python shell only to discover it doesn’t work…

    • Haven't seen this - shouldn't this always work on unixy platforms? If using readline/editline it works, and if built without it also works.

      1 reply →

  • > e.g. shell motions between macOS and reasonable OSes.

    I forgot about this since I started NixOS/home-manager everywhere.

That's great. I've been using terminals for 20+ years, and never new about CTRL-U. Thanks! TIL.

  • It's built into the Unix terminal driver. Control-U is the default, but it can be changed with e.g. "stty kill". Libraries like readline also support it.