|
|
|
|
|
by greenspot
3438 days ago
|
|
Great post & thread, a tl;dr: Ctrl-r search history
- then Ctrl-r again to show next match
- then Tab to show all options
Ctrl-p previous command or arrow up
Ctrl-n next command or arrow down
export HISTCONTROL=ignoreboth:erasedups
Add to .bashrc to avoid duplicate entries
Ctrl-a to beginning of line
Ctrl-e to end of line
Alt-b one word back
Alt-f one word forward
Ctrl-k delete to end of line
Ctrl-u delete to beginning of line
Alt-d delete to end of word
Ctrl-w delete to beginning of word
Alt-Backspc same
cd - change to last dir
pushd <dir> mark current dir and go to <dir>
popd go to marked dir
z fuzzy cd, install from https://github.com/rupa/z
j fuzzy cd and more, install via autojump
Ctrl-z to background & suspend
bg recent background app continue running
fg bring recent background app to front
disown -h remove recent background app from current tty
fg %n bring nth app to front, e.g.: fg %2 for second
less better than cat, doesn't flood screen, same keys
find find files, e.g. find / -name <filename>
ag install via the_silver_searcher, faster grep
tree shows dir like a GUI app, install
!! last command, e.g. sudo !!
fish bash alternative with more sensible defaults
man bash read more about bash
|
|
This is very useful. For instance, if you remembered that you didn't `mkdir /mnt/disk` while in the middle of the command `mount /dev/sdb /mnt/disk`, you can delete what you have already typed with Ctrl-u; issue `mkdir /mnt/disk`; than you can paste the previous command with Ctrl-y. Very useful and I use it all the time! (Ctrl-u have never tied to my muscle memory, so I usually do Ctrl-a Ctrl-k to move to the beginning of the line and delete what comes next).
Other tips:
I also put these in my .bashrc for searching history pressing up/down. This is different of searching with Ctrl-r. When you type part of a command, such as and press up, it will complete with previous ocurrences of commands starting with `mkdir /dev`. It is faster than Ctrl-r if you already know what to do.