Skip to content

Instantly share code, notes, and snippets.

@anonRegions
Forked from nahurst/history.sh
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonRegions/f1b52ad5125ea54ab743 to your computer and use it in GitHub Desktop.
Save anonRegions/f1b52ad5125ea54ab743 to your computer and use it in GitHub Desktop.
# set these in your .bash_profile, .bashrc, .zshrc first
HISTFILESIZE=100000 # how many lines to keep total
HISTSIZE=100000 # how many lines to keep for the current session
# oh-my-zsh will default to a reasonable 10000, but most bash defaults to a few hundred
# oh-my-zsh by default appends all commands to history after they are run instead of on session end
# search the history with control-r
# search for commands starting with the one you typed with alt-p
# if you don't want something to stay in your history, prefix the command with a space
# on zsh, setopt HIST_IGNORE_SPACE
# most used commands
history | tr -s ' ' | cut -f3 -d ' ' | sort | uniq -c | sort -nr | head -n 30
# most used commands including args
history | tr -s ' ' | cut -f3- -d ' ' | sort | uniq -c | sort -nr | head -n 30
# when you forget to sudo
sudo !!
# when you don't want to type out the args again
cp a-very-long-file-name.txt a-very-long-file-name.txt.bak
subl !^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment