Tuesday, March 4, 2008

shells




For some time I had been trying to come up with an elegant solution for starting all the multiple shells I need when working on my Ruby on Rails projects. I find that if I have the following shells, it really helps with command history:

command-shell
svn-shell
ruby-shell
console-shell
migrate-shell
test-shell

In the command-shell, I run normal commands, like "script/generate model InputAffinity". In the svn-shell, I interact with subversion. In the ruby-shell, I run commands like "mongrel_rails cluster::start". In the console-shell, interact with the Rails console ("script/console"). In the migrate-shell, I do my migrations, and in the test-shell, I run my Rails tests.

I was getting tired of starting all those shells, and tried various complicated elisp expressions to start shells and change the starting directory in each of those shells. It turns out that there is a very elegant and super simple way to do this.

1) Add the following to your .emacs startup file


(shell "command-shell")
(shell "svn-shell")
(shell "ruby-shell")
(shell "console-shell")
(shell "migrate-shell")
(shell "test-shell")


2) "cd" into the Ruby on Rails directory

3) Start emacs normally.

So simple, and so good.