Pinjasaur
10/2/2017 - 4:08 AM

Bash

Bash tips & tricks

Bash

Directories

dirs shows the stack of directories. dirs -v shows them vertically with their indexes. Recommend aliasing dirs to dirs -v.

pwd is always transient at the top of the stack.

Reference directories with ~[index] where [index] is the directory stack index.

Commands

history shows commands for user.

Reference command with ![command] where [command] is the index from history or the most recent command beginning with [command].

PROTIP: Append :p to print instead of exec.

!! is the last command ran. sudo !! is amazing.

Reference command args with ![command]:[index] where index is the arg index.

Can also use ^ for first, $ for last, and * for all.