Lately I've been using TextExpander to make my workflow a little easier when dealing with things like Django development.
I've owned TextExpander for a while, but never really came up with something useful to do with it until recently. I found myself typing the same thing over and over when dealing with the web app that I'm working on in Django, and came up with some tidbits that help ease this process.
Some of the things I'm doing here would normally be the domain of shell scripts. However, to actually run a shell script in a typical manner I'd be typing practically as much stuff as I am to actually type some of the commands. Most of them aren't actually all that long.
So I got the idea to enter some shell commands in TextExpander and see where that took me. According to the TextExpander stats, I've now expanded 102 snippets, saving myself the need to type 3,148 characters.
This first example goes into my Django source code folder, checks out the latest version from subversion, and installs it. Because it's just running the commands in the terminal, it does everything perfectly and asks for my password when necessary.
cd ~/Source/Django/ svn co <a href="http://code.djangoproject.com/svn/django/trunk/">http://code.djangoproject.com/svn/django/trunk/</a> django-trunk cd django-trunk sudo python setup.py install
So instead of going to the Django site, finding the link (because I always forget it), pasting it in Terminal, and running the install command I just type “dco” at the command line and type in my password when it asks for it. This same basic idea could be applied to anything you check out frequently. Since I'm just downloading the source code and not actually contributing anything to the Django project, I don't need any of the more advanced elements of subversion. Just the ability to check out a read-only copy of the latest version of the source code.
I also have some simpler snippets that also save some time. Like, instead of typing:
python manage.py runserver
every time I want to start up the development version of a Django app, I just type “rrs” and it runs. I include a carriage return at the end of that line in the snippet so that it automagically hits return for me in Terminal.
That snippet is obviously not project specific, so I can run it in any Django project folder to run that app. In addition to that, then, I enter shortcuts for the actual project directories as separate snippets. So typing “ddt” enters
and follows it up with a return to take me right into that directory. Then I can hit “rrs” to run the app or “sdb” to run
python manage.py syncdb</pre></div>
if I've made any changes that require the database to be updated.
If I need to install any python modules I've downloaded, I can usually just cd into the directory and then type “iinst” which gives me
sudo python setup.py install
followed by a return, and then type my password.
Obviously these things can be applied to any programming language or other frequent commands you type. It's made my command-line life a lot easier.
September 26, 2008