Read my book

I wrote books about Webpack and React. Check them out!

Tuesday, July 16, 2013

13 Ways to Get More Out of OS X and Terminal

It is amazing how small things make a big difference in the daily grind. I thought it might be fun to go through some of my favorites.

Manage Dotfiles Effectively

Files of dots by
This is something I've covered earlier briefly. As I stated in that post I like to use Dropbox to sync between my systems. Since then I've set up a git repository that contains the essential settings. When I need to use my dotfiles somewhere, I simply clone the repository there and set up symlinks and clone my favorite Vim plugins using a little script for that.

If you consider this approach, keep in mind that you cannot put anything in the repository. Keep your private stuff, like ssh keys and such, out of there and you will be just fine.

Show Active Git Branch

Branch by Kat...
If you work with multiple Git based projects, it can be handy to show which branch you are currently in. In case you check out my dotfiles, you'll see I use something like this there. The script looks a bit weird but works alright if you are on bash environment. In addition I have configured mine to show a '*' character in case there is something in the stash.

Discover Creative Commons Photos

Finding good photos, especially Creative Commons ones, can be difficult. I like to use Creative Commons based photos as the licensing can be quite permissive and is absolutely perfect for blogging. In commercial usage you might need to be more careful due to that NC clause. Even then simply asking a permission is worth a try.

I like to use Compfight for finding these photos. It is a search frontend for Flickr. The clean interface is very utilitarian and gets straight to the point. Just remember to the filter correctly.

Get Screenshots Easily

As you might know, there are some cool shortcuts for taking screenshots in OS X. I like to use Command-Shift-4 a lot as it allows me to crop the shot instantly. By default it outputs the screenshot to the Desktop. In case you wish to output it elsewhere, execute defaults write location ~/Pictures/ at terminal.

Position Your Windows Fast

The default window manager of OS X is a little bit disappointing. Sure, screens are fun and work fine after you configure them correctly (disable "Automatically rearrange spaces based on most recent use" at User Preferences, Mission Control). Managing the windows can be a bit tedious by default.

I like to use a small utility known as DoublePane. It simply provides configurable shortcuts that allow me to orient a window to left or right. There are also shortcuts for displaying a window in a full screen and restoring but I rarely use those. It's that orient left/right that's valuable for me.

Make CapsLock Do Something Useful

Are you ready to unleash the fury?
by John C Bullas
CapsLock is my nominee for the most useless key in the keyboard. Fortunately it is very easy to make it do something useful. I have remapped it to Escape. If you are a vimist, you understand why.

This can be achieved in two steps. First of all you will need to rebind it via User Preferences, Keyboard, Modifier Keys... . I've set it to ^ Control myself.

We're halfway there now. We still need to rebind that key to something useful. I've achieved this by using KeyRemap4MacBook. It is one of those applications that allows to you do some fairly crazy things. Despite the name it works on iMac and co.

In order to remap the ^ Control key, I've activated Change Key, Change Control_L Key (Left Control), Control_L to Control_L (+ When you type Control_L only, send Escape). As that sounded more awful than it is in reality, consider the screenshot below:


Adjust Display and Audio by Quarter

Wouldn't it be neat if it was possible to adjust display brightness or audio loudness by quarter? As it happens, Apple engineers have made that possible. Simply press Alt and Shift while adjusting. If nothing else, this is a sure way to impress your hipster friends at café.

Paste Without Formatting

Isn't it awful when you paste some text only to realize it pasted the formatting too? Fortunately there's an easy remedy for this. Simply keep Shift pressed while pasting. So Command, Shift, V stands for victory in this case.

Copy and Paste File Contents

OS X comes with a pair of amazing utilities known as pbcopy and pbpaste. They allow you to copy and paste within terminal. If you have something in the clipboard, simply pbpaste > file.txt to extract it to a file. pbcopy < file.txt to copy file contents into clipboard.

Navigate File System Effectively

Navigating file system is very slow and boring by default. It is easy to supercharge your navigational capabilities simply by using autojump. It keeps track of where you have visited and builds an index based on that. Then you simply j name around.

I know I have covered the utility before. It is so good it is worth mentioning again.

Search Code Effectively

Even though grep is great and all that, I've found myself using The Silver Searcher as a replacement lately. It is fast and comes with sensible defaults. Definitely worth giving a go.

Replace Terminal with Something Better

The default terminal of OS X isn't that great. If you are looking for something better looking and robust, consider iTerm 2. The default font is not quite ideal and I recommend replacing it with something else. You can do this through iTerm, Preferences, Profiles, Text. The screenshot at the left should help.

As you can see from the screenshot, I like to use inconsolata-dz. It is a version of the famous inconsolata with straightened quotes.

Installing the font is quite easy. Simply download and extract it. Open Font Book and then File, Add Fonts... .

Manage Credentials Effectively

As the amount of services you use increases, the amount of credentials you must remember simply keeps on increasing. This leads easily to some bad behavior. You might use the same password for multiple services for instance. That's not a very good idea as in case some of the services gets compromised, you have a lot of work ahead of you.

Because I don't like having to remember too many passwords, I use 1Password. It acts as a proxy for the services and provides simple means to manage and create them on demand. It is a definite time saver. I've set it up so that it uses Dropbox to sync between my systems.


I hope you found some of these tips useful. Feel free to share your favorite tips and tricks below in the comments!