Rails + Windows Command Line Tips
August 16th, 2007
We do lot’s of things from console when using Rails and it can be a little painful on Windows. However, we can try to make our lives better.
To begin with, I must confess in being a great lamer. I always used Windows (Update: Finally on Ubuntu!) (except some crazy attempts including a night session of trying to run MacOSx86 on VmWare, qemu and kqemu under Linux on a processor that doesn’t support SSE2), never used things like Far manager (the tool used by all crazy Windows guys, well, at least in Russia), never wrote bat files (except the ones in the University that were considered to be viruses by AVP for some reason), never managed to remember all those tricky keyboard shortcuts, nothing.
But once started to use Rails I began to love The Console. Really, lot’s of things can be done easier and faster. But there are several things I don’t like about the Windows console (cmd.exe).
First of all, I use gems documentation a lot. The one that can be accessed from the browser on the 8808 port (by default) when you run gem_server. It’s cool. The only thing I hated about it is that I had to run it every day and that its console window was hanging about the desktop. So I’ve found a nice tool called Hidden Start that allows to run console applications in the background without any windows. So I’ve simply added it to the Startup folder and now I can access RDoc gems documentation instantly!
The next thing I do very often is starting the console session to run tests, rake tasks or other things against my Rails application. The thing I hated is that I had to change the current directory (home directory that is opened by default when one starts cmd.exe) to the directory of the application, which always took a while cause I’ve had to change the drive and type the long path to the application. I wanted just to open a console and type a command without changing the directory. It appeared that one can change the default cmd directory by hacking the registry, but I didn’t want that cause I have several applications that I want to use console with. So I created a shortcut for cmd that opens the console window and sets the current directory (I’ve found the parameters somewhere on the net):
%windir%\system32\cmd.exe /k "cd /d d:\really_long_path_to_my_rails_project"
The last thing is the Rails Application Server. I currently use Mongrel, but it doesn’t really matter. Every day I had to open the console window, change the directory (Shit! Again!) and run ruby script/console, which I also hated of course. This time a simple bat file saved my hair (at least for a while):
cd /d d:/really_long_path_to_my_rails_project
ruby script/server
I’ve added the above mentioned 2 files to my quick launch panel and now I feel happier! But as stated, I’m a lamer, so I’ll be grateful to hear ideas on how to make it better.
Leave a Reply