I just got a new MacBook Pro and took the time this morning to set up my bash command line environment. I realized I’d gotten used to a lot of things over the years that don’t come out of the box. And so, in no particular order, here are the things I did to trick out my bash shell.
iTerm2
This almost doesn’t count because it is a straight up replacement for the built-in terminal, but once you get used to iTerm2, you won’t ever want to go back to the stock terminal again. This application gives you the ability to finely control all aspects of your command line environment. There is so much functionality here I won’t even go into it. Just get it. Try it. Love it. And never go back.
Color Scheme
This may not count as a complete trick in and of itself. It is really is just adding even more love to iTerm2, but I think it warrants adding to the list.
Adding some flair to iTerm2 is not hard, There are dozens of color schemes you can apply to it. I am running the Homebrew scheme, which I got from this great repository of iTerm2 color schemes.
The Homebrew color scheme I mention here has nothing to do with the Homebrew tool we explore next.
Homebrew
I would be surprised if you are a developer on a Mac and don’t know about Homebrew. It’s a package utility that lets you install other software, which I used when installing many of the other things below on this list. Having Homebrew at your fingertips is as handy as a pocket on a shirt.
Bash v4
Apple ships Bash v3.* with the MacBook pro, but it’s easy to upgrade to Bash v4. Here is a nice blog post covering how to do so. Admittedly, this change is most likely to make a difference for you if you are doing some significant shell scripting, but I like to always have latest if I can get it, so why not?
Auto-Complete
Nothing drives me crazier than not having auto-complete on my command line, which essentially just let’s me tab through commands easily. So, for instance, I can cd into the Networking folder by typing cd Net<tab>. It’s just too awesome not to have. The same blogpost as the one above covers getting auto complete running in your new shell.
Case Sensitivity
Also irritating to any but the most diehard command line gurus is the case sensitivity of navigating through your directories. The below StackExchange article summarizes nicely how to make navigating your directory structure a case insensitive pleasure.
Bash Git Prompt
Although this overall set of tips and tricks isn’t about Git, those reading this article likely do use Git. So, for those of us who git it, you’ve GOT to trick that command line when it’s in a folder that lives in a Git repo. The awesomeness I am referring to is bash-git-prompt.
This utility has so many customization options it’s ridiculous, but the main intent is to provide information about the state of your repo, files, etc., right on the command line. It does so very well and it’s a beautiful thing. Now you can see which branch you are on, how many commits ahead you are, whether your directory has dirty or untracked files in it, all in one simple view and omnipresent right there on the command prompt itself.
Command Aliases
I also have a lot of commands that I like to alias in my .bash_profile fie. It’s great to alias long, strung out docker, git or other commands, but here are some silly ones I love. They just make navigation easier for me.
alias ..=”cd ..”
alias …=”cd ../..”
alias ll=”ls -GFHAf -1″
Wrapping Up
There is a lot you can do to really pump up the capabilities and user-friendliness of your command line. Doing so can make your experience using it a real pleasure.
I hope you find some of these helpful and would love to hear about your favorite command line hacks, tips and tricks.