Richard Gould

CTO, Software Developer, Language Learner

Screencast: Using Shell History to Create Aliases

| Comments

Contents:

  1. Introduction to aliases @ 0:00
  2. Analysing shell history to create relevant aliases @ 4:43

Download: mov 24MB, 8:26 (Recommended)

Watch (recommended in full screen and in HD):

Notes:

Make an alias:

    alias l="ls -al"
    alias glog="git log"

Add those to your ~/.aliasrc.

Modify ~/.zshrc or ~/.bashrc (works for both):

    if [[ -r ~/.aliasrc ]]; then
      source ~/.aliasrc
    fi

View shell history: history

View count of common commands:

    history | awk '{ print $2 }' | sort | uniq -c | sort -n
    history | awk '{ print $2,$3 }' | sort | uniq -c | sort -n

Use that output to create better aliases!

Here’s some of my favourite aliases:

    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../../'
    alias .....='cd ../../../../'
    alias be='bundle exec'
    alias g=git
    alias ga='git add'
    alias gc='git commit -v'
    alias gca='git commit -v -a'
    alias gch='git checkout'
    alias gl='git pull'
    alias gst='git status'
    alias l='ls -al'

Comments