Fork me on GitHub

Random awesome Unix commands

Call the last executed command

With !!.
For example: clear && !!.

Call the last command that starts with a specific keyword

With !keyword.

!v will call the last command that starts with v, vim /etc/sudoers for example.

Recursive search

With ^R.

Type a keyword and it will search for the last command that contains it.
If you want the command before, simply ^R again.

mkcd

mkcd () { mkdir -p "$*"; cd "$*"; }

mkcd /tmp/foo will mkdir -p /tmp/foo and cd into it.

Add it to your bashrc (or zshrc) to make it easier on you.

A shortcut for "clear"

^L

Automatically type the last commands' last argument

With Alt + ..

Example:

vim    ~/.bashrc
source # If you use the shortcut, `~/.bashrc` will be automatically typed

Moving inside the CLI

This: Shortcuts to Move Faster in Bash Command Line.

Tags: unix