Shell aliases (not only) for Rails developers

Patrik Bóna
Patrik on Rails
Published in
2 min readNov 18, 2017

In this post I am going to show you how to be more effective with command line interface thanks to the shell aliases.

A shell alias is a shortcut for a longer command. There are two types of aliases I use.

One is for commands which I use a lot. Why to type vim when I can type just v? Why to type bundle when I can type just b? Or vagrant up instead of vu?

The other is for commands which are hard to type and hard to remember. Instead of this:

git branch --merged | grep -v "\*" | grep -v "master" | xargs git branch -d

I use delete_merged_branches. I could probably use something shorter, but delete_merged_branches is so entrenched in my muscle memory, that I will probably keep it forever. Also, I use auto completion with it so I never type the whole name.

Check the following screencast for few more examples:

You can see all of my aliases in my dotfiles repository. But don’t copy them.

If you just copy someone’s else aliases, then you can end up with a lot of aliases which you don’t use. The same thing happened to me when I created my dotfiles from thoughbot dotfiles. I cleaned up a lot of them since then, but there is still some bloat.

Try to identify commands which you type often, complex commands which you use regularly and define an alias for each of them so you don’t need to type or remember them anymore. This can save you a lot of time from a long-term point of view.

I hope that this post inspired you to create your own shell aliases. If yes, then feel free to share them in the comments.

Do you want to learn more about CLI hacks? Then subscribe to my newsletter and shoot me an email!

--

--