Your terminal is a blank slate for parsing and navigating the wide range of information you interact with as a developer every day. Over the years, I’ve set up a few shortcuts in my terminal that save me time during projects, cut down on keystrokes, and reduce errors for some repeated commands.
Change Directory Aliases
alias ..="cd .."
alias ...="cd ../.."
alias .4="cd ../../.."
This is easily my most used shortcut in my terminal settings. While the difference between
cd .. and
.. is obviously small, it allows me to navigate so much faster through directories. Doubly so when it’s a group of directories I’m not as familiar with and am doing some digging or exploring. The
... is particularly useful, as it turns eight keystrokes to three. Again, not groundbreaking when done once but with how often I use these commands, it adds up. It becomes painstakingly obvious how useful it is when I’m on another machine or connected to a remote server where I can’t edit the aliases.
.4 may be a bit overkill, as it’s fairly easy to visualize two or three layers of directories but, at least for me, it starts getting a little fuzzy at the 4th level. I mainly have it because I know if I’m in a typical Rails app directory, using the
.4 will take me back to the desktop (/Desktop/dev_folder/project/app).
alias gb="git branch"
alias gc="git commit"
alias gco="git checkout"
alias gs="git status"
My Git aliases are a close second behind the change directory aliases in terms of frequency of use. These are helpful not just in having fewer keystrokes but in saving time having to re-enter misspelled commands. I know I have entered
gi tbranch, or some other erroneous combination of these commands hundreds of times prior to these aliases.
Being able to quickly and correctly enter these common commands has definitely allowed me to be more efficient in the git commands I use most frequently.
If you’re using ZSH (especially oh my zsh like we do), take the time to experiment with themes! Having information displayed in a way that allows you to quickly scan, parse, and input information can save loads of time. Personally, I use the oh_my_zsh theme dallas. Not only do I like the color configurations it uses, but the inclusion of the file’s Ruby version and current git branch has saved me on multiple occasions!
If you can’t find a theme with the right mix of options, colors, and formatting to maximize your terminal exploration, make your own! Be sure to share it if you do so others can also benefit from your theme.
Rails Specific Aliases
alias be="bundle exec"
alias rake="noglob bundle exec rake"
These two relate specifically to Ruby on Rails development and are extremely useful for that purpose. We have certain projects that require appending
bundle exec to many commands so the first alias helps save time and ensure accuracy there. The second is oh_my_zsh exclusive but has made my life infinitely easier.
There can be issues running rake using oh_my_zsh and this alias makes it so I do not have to worry about those errors repeatedly cropping up.
alias project1="cd ~/dev/client/project1"
alias pa="cd ~/dev/pa/pa_project"
alias acme="cd ~/dev/acme/acme_store"
These are more specific Change Directory aliases. I have these assigned to all of our applications and projects, which makes jumping around much easier. I especially like these commands when a coworker has a quick question about another project. Instead of several
cd .. or trying to remember the exact path of a project, all I need to do is enter the short alias, look at the code the coworker is referencing, then use another quick alias to be back to the directory I was originally working in.
Anything that makes context switching a bit easier and less distracting should always be welcomed by a developer!
These settings and shortcuts help me move quickly and accurately from my terminal. What settings have you implemented in your terminal? Leave a comment below with your most-used settings.