Skip to content

Instantly share code, notes, and snippets.

@nahurst
Created June 10, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nahurst/ce1dba51490586da487a to your computer and use it in GitHub Desktop.
Save nahurst/ce1dba51490586da487a to your computer and use it in GitHub Desktop.
Teach us something technical: command line
# 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