Looking for shell aliases

Anyone who spends time in a shell (sh, bash, zsh) knows that aliases can greatly help with productivity through the reduction in typing and typing mistakes.

Most shells come with some already set, such as ll for ls -alF, so you can see details of the current directory:

-rw-r--r--    1 mark  staff     703 27 Oct 11:01 tsconfig.json
-rw-r--r--    1 mark  staff  149291 24 Mar  2022 tsconfig.tsbuildinfo
drwxr-xr-x    7 mark  staff     224  2 Jun 10:03 utils/
-rw-r--r--    1 mark  staff  399679 24 Mar  2022 yarn-error.log
-rw-r--r--    1 mark  staff  422743 27 Oct 11:01 yarn.lock

You can add any others yourself to your shell init script such as .bash_profile. Here are a few I use:

alias dc='docker-compose'
alias ggraph='git log --oneline --graph'
alias gs='git status'
alias gversion='echo $(git describe --abbrev=0 --tags)-$(git log -1 --format=%h)'
alias k='kubectl'
alias tf='terraform'

I use docker-compose and terraform all the time so I have aliases them to dc and tf respectively. The gversion alias helps me know what the current version of my code will produce when I build and tag a docker image.

Recently I was looking at my day-to-day workflow and how to speed up what I’m typing. I decided to look at my history and see what I typed a lot, and here is what I found.

Running the following in a terminal after a few hours shows:

history | awk '{print $2}' | sort | uniq -c | sort -n
  27 czctl
  28 curl
  29 k9s
  34 tmux
  38 k
  46 npm
  58 more
  68 ls
  71 vi
  84 yarn
  91 cd
 180 git

I’m already making good use of my alias for kubectl as k, but I see to type git and yarn a lot, so I’ve added aliases for them.

alias g='git'
alias y='yarn'

This is something I’ll keep doing every couple of days until I get my most frequently used commands as aliases.

Leave a comment

Your email address will not be published. Required fields are marked *