It seems like everyone has a use for Terminal these days but the people most uncomfortable with it (think PMs, designers) have the heaviest lifting to do. Shortcuts are so wildly helpful for making Terminal approachable—yet are somehow unexplained and impenetrable for those that need them.
Here’s my attempt to fix that.
The long way
Repeatedly typing in the same commands into Terminal is annoying, takes time, and is prone to mistakes. Let’s look at some examples of my common commands to illustrate this.
To navigate to my personal site’s local folder, I’d manually type:
That would almost always be followed up by the command to start the local Jekyll server to preview changes to that site:
bundle exec jekyll serve
And then I’d want to open this folder up in Atom. I don’t even know how to do this long-hand in Terminal so would probably just navigate to said folder via Finder and drag it onto Atom’s app icon.
A bit painful.
The quick way
You can shorten these commands into shortcuts of your choosing. My shortcuts for the above three commands are
atom respectively. So to get those same three things done, I’d instead write:
me jek atom .
Let’s give it a try. Open Terminal and type
nano .bash_profile. This should create and open the .bash_profile file inside of Terminal.
Here’s what mine looks like with shortcuts already made at the bottom:
Notice the syntax that each of my shortcuts are using? Here’s a breakdown:
alias: as the word suggests, this defines the following will be an ‘alias’, or shortcut.
your-shortcut-name: replace this with your desired shortcut word; what you will type in Terminal to actually do that longer, gnarlier thing. If your shortcut is to open Visual Studio Code, you might write replace this with
"whatever-you're-shortening": if your shortcut is to navigate to a directory, you would replace this with
"cd ~/My Folder/". If your shortcut is to open an application, you would replace this with
"open -a App Name".
Simply add any of your desired shortcuts to the bottom of this file, above
source ~/.bashrc. Save .bash_profile and restart Terminal. Your shortcuts should now work.
The pro zone
I don’t even need to fuss in Terminal now that I have an application shortcut for Atom. Instead of writing the command
nano .bash_profile, I can use my fancy shortcut
atom .bash_profile for a nicer experience.
Keep an eye on an nearby engineer as they use Terminal. You might see them use shortcuts beyond applications and directories such as using
git commit. It’s all up to you. Colours, ASCII art, and things I’m yet to figure out are also customisable via .bash_profile.
Shout out to Stephanie Coleman who introduced me to all of this at Kickstarter.