Every Day
Every day is exactly the same. Well not quite. But mostly.
While we always apply our programmer brains to different tasks, we generally do so using a common set of tools. It is worth spending a little time to optimize for usage patterns and let us use our precious time on more worthwhile endeavours. More importantly, pressing too many keys to do menial things is a pain in the arse. Let’s be more lazy.
Theme Song
Here is a unordered grab-bag of some of the trivial things I find useful in simplifying some daily tedium.
Bash
Using mintty gives you a nice shell in windows; don’t leave home without it! If you aren’t familiar or comfortable with a shell, there is no better time than now to learn. Stick with some basic tool till you get comfortable; grep, sed, simple bash scripts.
I tend to be working in a few directories at any given time, so I like to ‘bookmark’ them and easily get to them as I need. They are usually fluid in a given day, so I need an easy way to set bookmarks as easy as go-to them. Here is my 5min .bashrc hack to give me ‘s1-3′ for store-bookmark, and ‘d1-3′ for goto-bookmark:
alias s1='sed -i -e"1c `pwd`" ~/dircache.txt'
alias s2='sed -i -e"2c `pwd`" ~/dircache.txt'
alias s3='sed -i -e"3c `pwd`" ~/dircache.txt'
alias d1='cd `sed -n -e"1p" ~/dircache.txt`'
alias d2='cd `sed -n -e"2p" ~/dircache.txt`'
alias d3='cd `sed -n -e"3p" ~/dircache.txt`'
Note: There are probably a million better ways to do this, and you can write all of them in the comments!
Vi
If you are faffing about in the shell for long enough, you’ll probably want to edit stuff in vi from time to time. Isn’t it a hassle to open up another file when you vi is already open? How about adding this to your .vimrc:
# lazy fileswapping
map ,, :bn # maps ,, key sequence to :bn (buffer-next) and presses enter
then from inside vi you can simply ‘:n some_file.ext’ and swap between files by simply pressing ,,. Using ,, is a good shortcut because you barely have to even move your hand; it’s like right there.
Note: There are probably a million better ways to do this, and you can write all of them in the comments!
Ever lose your .vimrc? Protip: steal someone elses, like here: regular expressions, right? They are a great tool for searching code, but can be hard to get into at first. Try simply setting your default IDE search to be regular expressions. Now you can use .* for wildcards instead of *. Keep this setting enabled and experiment little by little with your every day code searching. With in mere decades, you’ll know exactly how many backslashes you need to escape your regex captures.
Autohotkeys
This is probably my favorite tool for getting to stuff quickly. On windows XP you can you use autohotkey to create shortcuts to your most frequent applications. For example, my config contains some things like this:
#1::Run C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
#2::Run C:\Program Files\foobar2000\foobar2000.exe
#c::Run C:\cygwin\bin\mintty.exe --exec bash --login
This means winkey+1 will run visual studio, winkey+2 will run music player, winkey+c will run a shell. There are also shortcuts for browser, home/dev folders, etc. Being more than one key away from a shell or IDE is a painful way to live. It will only take you fifteen minutes to fix it forever!
Note: On Windows 7 you can ‘pin’ things to the task-bar, which gives you similar functionality. On Mac and Linux, you can install a virtual machine and install Windows 7, which gives you similar functionality.
Minor Note: Running applications from here uses the environment variables you set when you run the base script! Don’t forget to re-run it when you want to use updated environment variables.
Rapid Environment Editor
I’m going to totally hijack this part of the article to link you to this wonderful tool: RapidEE.
If you deal with environment variables in windows and if you are a developer you probably do far more than you would like to, then this tool will make life much much better.
Summary
Use this stuff! Modify your environment! Make more shortcuts. Don’t open My Computer and dig through folders one at a time, press win+C, d1 and be where you want to be immediately. Save your precious time for doing interesting and useful things, instead of wasting 2% of every day crapping about in folders or starting up applications akwardly.
If you have any useful things you can add on this topic, please do so below!