How to be more productive with aliases and track down your bad habits

The original post first appeared on my coderwall profile on Jun 6. I don’t feel that coderwall protips are as easily accessible as it used to be so I decided to ‘reprint’ the post here.

The post has also been updated, and it should read:

10 sure-fire ways to be ultra-awesome-uber productive in less than 9 days1

Yesterday Some time ago I’ve found an interesting article / primer to bash scripting.

What interested me mostly, though, was command that displays top 10 commands I’ve used:

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl |  head -n10

As I have successfully moved from RubyMine IDE to Vim / shell for git operations, it’s not a surprise that my top 10 is was:

1	163  44.2935%   git
2	50   13.587%    cd
3	32   8.69565%   vagrant
4	17   4.61957%   ember
5	9    2.44565%   .
6	8    2.17391%   cat
7	7    1.90217%   pwd
8	7    1.90217%   ln
9	6    1.63043%   pg_ctl
10	5    1.3587%    ps

Top 10 commands after 6 months

1	3886  38.8639%   g
2	1444  14.4414%   git
3	544   5.44054%   ember
4	392   3.92039%   cd
5	346   3.46035%   npm
6	292   2.92029%   ls
7	200   2.0002%    rm
8	137   1.37014%   rspec
9	128   1.28013%   cat
10	117   1.17012%   rails

I have collected more data, but a few things deserve some explanation:

g vs. git

A team member, Maciek, made me realize that with zsh shell I can replace git with g alias. It took me roughly 3 weeks (21 days) to get out of the habit of using git and replace it with g.

I observed the 21 days to change habits principle2 over and over again during past few months. It took me similar amount of time to switch from :w to [CMD] + [S] in MacVim.

I’ll write a separate post about that as this kind of life-hacking interests me most.

Git as Vim is my Swiss Army knife. Knowing what’s going on gives you performance boost and confidence to try out alternative solutions.

It is also worth noting that with ember-cli, ember and npm are my next most used commands.

Though cd has the same length as .. (zsh alias), zsh allows me for .... (cd ../../ if you’re wondering) ;)

Using Vim / shell made me more aware what’s going on, about patterns I come across and, in turn, how to optimise them.

git aliases in retrospect

The original git aliases

rb = rebase
rbi = rebase -i
rbc = rebase --continue
rba = rebase --abort
rbm = rebase master

are gradually being replaced with either aliases from zsh like:

# Before (`git com`)
com = checkout master

# After

or custom ones:

# .zshrc
alias git=hub
alias gpr="hub pull-request"
alias gcoo="git checkout --ours"
alias gcot="git checkout --theirs"

After all, g rbi head~10 is better than: git rebase -i head~10, don’t you think?!

I also noticed that using short aliases like g rbi play nicely with history search (C-R). Searching for full version, e.g rebase -i (or rebase to be faster) returns more ambiguous results. Another small win! ;)

It may seems to be an exaggeration, art for the art’s sake, but I don’t care.

One keystroke less a day, make my wrist surgeon away!
One keystroke less a day, make carpal tunnel syndrome surgeon away!
Ryrych W.

Still not convinced? Read how best count each keystroke.

Switching branches updated

Originally I wrote:

Another pattern I used over and over again concerned pushing __local_feature branch__ to __origin__ (the same branch name).

git push -u origin feature_some_branch_with_fancy_name

Most often autocompletion is not enough, so I found this command in some gist:

gbn () {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'

With this, it’s better:

git push -u origin $(gbn)

I stopped using it after some time. Perhaps it wasn’t that powerful. ;)


Web developers use git on a day to day basis from shell or some IDEs like RubyMine. There may be time when you hit the wall when RubyMine will make some mess with your VCS. You will have to fall back on CLI version of this VCS. Wouldn’t it better to challenge yourself and switch to CLI version now? You won’t regret it! You will be able to even shout Brag. Blog. Blob!

More resources

  1. Love these titles ;)

  2. It’s less overrated than Pareto Principle