Do you need bash aliases?

August 11, 2019

How many commands, long or short, do you type multiple times a day? Could you be more efficient on the command line? I learned from early on, and I am still learning that I was not utilizing the tools I had to make me a competent terminal user. Having already used many aliases, I wanted to know what patterns and commands my day consisted of, so I set up a couple of tests.

Running Tests (My Average Day)

  1. Start of the day, coffee
  2. Empty out my bash history
    rm ~/.bash_history && history -c
  3. Work (write tests, write code, run tests, fix tests)
  4. Attend Meetings (Think about Why I Suck At Rocket League)
  5. Back to my desk (Review pull requests, check server logs, more coffee)
  6. Before leaving for the day, check my command history
    sort ~/.bash_history | uniq -c | sort -nr | head -n 50

Results (Simplified)

The results have been cleaned up to make it easier to read and to remove sensitive information.

 157 clear
 127 git status
  40 git add .
  26 ls -lA
  23 git add .; git status;
  12 git push
  11 cd ..
   9 docker-compose up
   8 docker container list
   7 npm install
   6 composer install
   3 docker-compose up --build

After reviewing what commands I run every day and scouring the internet, I compiled a list of useful aliases that I have started using.

Check out a related post: Useful Bash Aliases

The biggest time saving aliases for me were the git and docker commands.

# Git Aliases
alias gs="clear; git status"
alias ga="git add --all"
alias gp="git pull --all -p"
alias gas="ga; gs"

# Docker Aliases
alias dup="docker-compose up"
alias dub="docker-compose up --build"
alias dcl="docker container list"

Community

You should check your bash history throughout the week and see what what commands your run most frequently. Feel free to share your results with us via our tweet.