Six Colors
Six Colors

by Jason Snell & Dan Moren

This Week's Sponsor

Kolide can help you nail third-party audits and internal compliance goals with endpoint security for your entire fleet. Learn more here. 

By Dan Moren

Command Performance: You complete me

Typing is the worst. We all agree, right? Unfortunately, typing is one of those computer staples: it’s just difficult to get away from. That’s why I’m a fan of anything that makes me type less. And while there are plenty of third-party resources that can simplify your typing needs, allow me to suggest one that’s been right in front of you this whole time, perhaps without you even knowing.

The Tab key.

Yep, that weirdo that sits between Caps Lock and the tilde key, waiting for you to switch fields or indent text, has another superpower up its sleeve. It’ll be familiar to anyone who’s spent a good amount of time in the command line, but it’s got its uses in the graphical portion of the macOS as well: the Tab key completes you.

Specifically, the Tab key provides a sort of look-ahead completion option, especially in tasks like navigating a directory hierarchy. For example, if you’re on the command line and you need to go to a folder buried deep within several subfolders, you have a few options. If you’ve got that folder’s Finder window open, you can just drag it in and Terminal will write out the path. But what if you don’t? You can keep changing directories—e.g. cd /System—and then using the ls command to tell you what’s inside if you don’t remember the exact name. To go faster, issue a single command to take you to the deepest level of the hierarchy: cd /System/Library/CoreServices. But when you’re in the middle of writing that command, you can’t exactly stop to check that the file or directory name is spelled the way you remember.

Enter the Tab key.

Tab Complete in the Terminal

Start typing the beginning of a directory, for example cd /Sys and then hit Tab. If there’s only one option, it’ll automatically be filled in. (And, even better, if that directory contains characters that the command line doesn’t generally love, such as spaces, it’ll automatically escape them for you, without you having to worry about it.) You can keep going on this ad infinitum: once it’s filled in System, you type Lib and hit tab again and, boom, Library gets completed. If there’s more than one possible response, say, you type cd /System/Library/Core, then it’ll pop up the various options: CoreAccessories, CoreImage, CoreServices. Just type the next letter of the one you want—s, say—and hit Tab again, and it’ll continue along its merry way.

Even better, this trick also works in the Finder! If you use the Finder’s Go to Folder command (Command-Shift-G), where you can type in a directory path, you’ll find that Tab completion is still there, ready to help you. It’ll even provide you a drop-down list of options if there are multiple hits.

Tab Complete in the Finder

Directory hierarchies aren’t the only place Tab completion works either. If you’re in the command line and can’t remember the end of that command for viewing your different network interfaces, but you remember for sure that it starts with if, just hit the old Tab key to provide you with any commands that start with those two letters, and it’ll helpfully remind you that it’s ifconfig.

So, the next time you glance down at your keyboard and wonder just what the heck that Tab key is doing there, remember that it just wants to be your friend, and perhaps save your distaste for a key that deserves it. Caps Lock, I’M LOOKING AT Y—whoops!

[Dan Moren is the East Coast Bureau Chief of Six Colors. You can find him on Twitter at @dmoren or reach him by email at dan@sixcolors.com. The latest novel in his Galactic Cold War series of sci-fi space adventures, The Nova Incident, is available now.]


Search Six Colors