There are two main aspects to enhancing programming productivity, and they are what I like to call physical (decrease actual human activity) and mental (knowing the smartest way to accomplish a task) types. Humans are slow, so I want to help you prevent that slowness from killing your face-melting programming dreams.
Stop typing so much!
One great way to enhance your physical productivity is, obviously, to type less. You know what you want to do and it should take no time for you to tell your computer to do it. On the command-line, we can do this most easily with smart aliases, and perhaps creating functions that streamline our tasks for us so that we can accomplish this.
I’m going to share with you a few techniques I use to cut the number of keystrokes I type significantly while boosting my efficiency, so break out Cygwin or your favorite terminal and let’s get started.
Find out what commands you use most frequently
Here is a quick command you can use to figure out the 10 most used commands in your history (learned from lifehacker’s post):
My top list included cd .., ls, grep, and ant just to name a few. Your list will differ. I probably use each at least a dozen to a hundred times per day. If we do some stupid averaging of time spent with those extra characters, we could make some completely unscientific guess that we can save about 20 minutes a day if we only had to type two or three characters (including enter) for each of these commands.
Create aliases smartly
Now we can take this list and create some aliases to shorten those commands most frequently used. I use bash so I’ll edit my ~/.bashrc file (create in your home directory, if it doesn’t exist), and you can edit the file pertaining to your shell adding something like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
You get the idea. There are obviously a lot more, but it’d get boring if I shared ALL of mine. I recommend aliasing many commands to just one character. Over time, it will become second nature and your command-line will burst in flames from your speed (I still owe Casey a new monitor… sorry buddy… forgive me?)
When an alias just won’t do
Now there are obviously times where you really don’t want to put it all in one command, you might not want cd && blah && stuff || mkdir -p foo/bar as an alias. Unfortunately, I see so so few people use command-line functions to their advantage, but they really help you automate tasks.
Suppose you want to grab a certain file off of FTP, but you’ll need to do it often as the file changes. Setup a function so you don’t have to do it physically:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
You can put whatever sequence of commands you want in a function to automate your task. This can get much more complex if you like, using variables and output from other commands, stay tuned. The more you automate, the better you get at it.
The point here is to express as much as you can with the least amount of effort. Keep building on your automation in this way and you’ll find yourself with much more time for more important tasks. Now go melt some faces!
Please share your favorite alias or function in the comments!