All Macs come with Terminal.app installed, but few people really use it unless they’re developers. Even most developers I talk to have barely scratched the surface of what you can do inside Terminal. Lets look at 5 tips that made my Terminal usage way more productive.
Create an Alias to Save Time
If you repeat a command more than once in a day then you need to think about automating it. I often have to navigate to the folder that contains all of the client web sites I’m working on. To make this repeated task easier I created an alias. Simply put, and alias lets you type in a short text string and Terminal knows it means a longer command.
To set up an alias navigate to your User folder (found at ~/ from Terminal) and open the .bash_profile file in your favorite text editor. To create an alias for a long change directory (cd) command copy the text below.
alias site=’cd /path/to/folder’
By typing ‘site’ Terminal would execute ‘cd /path/to/folder’. That changes 18 characters typed to 4, and you only save more time the longer the command is. I have alias’ set for logging in to frequent SSH locations, deploying code on projects and a host of other frequently used commands commands.
Quick Look from Terminal
Terminal only provides a text based file view which isn’t always the easiest way to figure out what file you need, particularly when browsing a directory of images. While you could open Finder and navigate to the file to use Quick Look, you’re already there in Terminal. Why take your hands of the keyboard if you don’t have to. Accessing Quick Look is as simple as using the ‘qlmanage’ command.
qlmanage -p “Filename.jpg”
The text above would use Quick Look to open the image file named. You even have tab completion on filenames so you don’t have to type the whole thing. Type just enough that Terminal can determine the exact file you want.
rsync for Speed
Yes you can drag and drop files to move them in the regular Finder, but there is a faster way to move large file sets. rsync comes installed on all Macs and is a file copy and sync utility. You can even use it to sync directories between you local machine and remote servers. Any time I need to move a set of files close to 1GB I reach for rsync.
rsync -rave –delete /source/location /destination/location
The command above will sync the two directories, deleting files that are no longer present on the source from the destination. If you didn’t want to delete files then remove ‘–delete’ from the command. You can even use this to make a full copy of your hard drive to an external. The best part is that rsync is incremental. If the transfer gets interrupted you don’t have to start it again, just run the command again and it will only transfer files that it didn’t transfer the last time.
If you’re transferring between servers it’s best practice to do it over a SSH connection since rsync does nothing to encrypt the files.
There is a lot more power in rsync than we’ve mentioned here so go read the documentation to find out all the things you can do.
Forget the Dock
Yes the Mac Dock was cool when we first got it, but moving from your keyboard to mouse and back again is slow. If you’re already working in Terminal just launch an application directly from the command line.
open -a Mail
Not only can you open an application, you can close it without leaving Terminal.
Don’t forget you could also alias the commands to reduce the typing even further.
You Need Finder Sometimes
As much as I try to avoid Finder, sometimes it is the best tool for a job. Instead of navigating to the directory you are currently viewing lets tell Terminal to just open a new Finder window at the location we are currently viewing.
Way faster than clicking through levels of folders to get to the same spot you were just browsing from Terminal.
A Bonus Time Waster
Yes this is the sixth tip, and no it will in no way make you faster. In fact if you watch the whole thing you’re going to lose a few hours of your day. Did you know you can watch Star Wars in ASCII from the Terminal? One simple command and you can watch Episode IV – A New Hope.
Now site back and enjoy the silent escapades of a Jedi.
So there are 5 basic tips that will help you do more in Terminal faster. Sure they only save seconds, but if you’re repeating a task many times seconds become minutes become hours really quick. Do you have any favorite Terminal tips that didn’t make the list?