How to read:
When I write
^A it mean I press
Ctrl-A, which is noted
Meta-a (it's left alt on current keyboards).
I avoid singleline prompt
Because of the following issue:
PS1='$ ' printf "pouette" ls^A ls -l^A
Issue is: readline have two ways to move at the beginning of a line, and have no way to know where the cursor is, and assume the line start at column 0.
Easy, daily, shortcuts
Killing and Yanking from the killing stack
C-a C-k: Move to the beginning, then kill the line.
M-y: Yank and yank pop.
$ git push origin HEAD^A^Kgit commit -m "FIX"^A^Kgit add -u C-y Enter C-y M-y Enter
C-a(beginning of line)
C-e(end of line).
C-n: like up and down arrows, to browse history.
M-c(lowercase, uppercase, capitalize)
C-l (clear screen). Oh, if it's not enough, like after killing
ENTER reset ENTER to ensure you type it in a clear
C-a C-k reset ENTER to avoid executing blindly.
$ man bash | grep '!!' !! Refer to the previous command. This is a synonym for `!-1'.
$ apt upgrade E: ... are you root? $ sudo !! sudo apt upgrade ...
shopt -s globstar:
$ rm **/*.md
$ find -name '*.md' -delete
sed -i '1i#!/usr/bin/env python3' **/*.py
Other shortcuts I use
And I like them for the nice symetry:
C-fto move forward a char,
M-fto move forward a word.
C-bto move backward a char,
M-bto move backward a word.
C-dto delete a char,
M-dto delete a word.
Pipelines for the win!
$ man bash | grep -C1 C-a Commands for Moving beginning-of-line (C-a) Move to the start of the current line.
Subshells for the win!
emacs $(git grep -l PATTERN)
Those are the same in emacs, save brain space, use emacs.