Skip to content

Instantly share code, notes, and snippets.

@Pinjasaur
Last active October 2, 2017 04:39
Show Gist options
  • Save Pinjasaur/a0171dd2e041f61300c9dd15f7d24969 to your computer and use it in GitHub Desktop.
Save Pinjasaur/a0171dd2e041f61300c9dd15f7d24969 to your computer and use it in GitHub Desktop.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment