Day: January 8, 2020

Nice Bash terminals shortcuts

Today Adam Feuer submitted a NuttX patch to changes NSH command line editing so ctrl-K deletes from char pos to EOL like GNU readline

Besides Ctrl+K you can use many others interesting shortcuts in the Bash:

  • Ctrl + A => move the cursor to the beginning of the command line;
  • Ctrl + L => Clear screen and move the command line to top of the screen;
  • Ctrl + W => Erase the word at left side of the cursor;
  • Ctrl + E => Move the cursor to the end of command line;
  • Ctrl + R => Reserve-i-search: search for a previously typed command line;
  • Ctrl + T => Exchange the left character with the character at right (current position case you are not using the vertical line cursor, see below)
  • Ctrl + U => Erase all characters at the left of the cursor until the beginning of the command file;
  • Ctrl + P => Same as arrow up, show previous command line;
  • Ctrl + F => Same as arrow right, move a position to the right;
  • Ctrl + H => Same as Backspace;
  • Ctrl + K => Erase all characters from current position until the end of the line;
  • Ctrl + Z => Case you are running a command it will make it a zombie and you return to command file. Useful when you don’t know how to close a program and Ctrl + C doesn’t work;
  • Ctrl + B => Same as arrow left, move a position to the left;
  • Ctrl + N => Same as arrow down, show next command line (case you moved to previous command line)
  • Ctrl + C => Case you are running a command, it will send a signal to kill the command;
  • Alt + . => Copy the last word from previous command files

This command will replace the square bar cursor with a vertical line cursor:

$ echo -e -n "\x1b[\x36 q"

If you want to return to previous cursor just type: reset and press enter.