I frequently change my development environment on my laptop. I have one setup for different projects I’m working on at Engine Yard and others for projects I work on in my free time. It’s a big pain to always have to manually set up the development environment. I always wished there was a way to just automate it all: loading up the applications I wanted, then setting up my application consoles, database interfaces and monitoring the test output of the project.
Thankfully there is Terminitor, a project maintained by Arthur Chiu, of the Padrino team. Terminitor has made my life more simple. Currently Mac OS X Terminal, Mac OS X iTerm and KDE Konsole are the main cores that it works for. To all the Windows users who?ve fallen in love with Rails Installer, if you?re starting to experience the pain of repeatedly setting up your environment, I suggest you go fork Terminitor so that it can give you some love too.
There have been some cool changes since the creation of the Terminitor gem. One change is the addition of the iTerm Core, which has been great, especially with the release of iTerm2. I know I am one of many people who have switched over from Terminal to it. The second major change is the addition of the Ruby DSL. Before you had to create your Termfiles using a YAML syntax that looked something like this:
# ~/.terminitor/foo.yml # you can make as many tabs as you wish... # tab names are actually arbitrary at this point too. --- - tab1: - cd ~/foo/bar - gitx - tab2: - mysql -u root) - use test; - show tables; - tab3: echo "hello world" - tab4: cd ~/baz/ && git pull - tab5: - cd ~/foo/project - autotest
Some people might like using this syntax. If you are one of these people, you can enabled it by using $ terminitor edit foo --syntax yml
. However, the newer Ruby DSL Syntax is much nicer and allows you to use it with a lot more complicated behavior such as window creation and setting up blocks that can be executed before loading a project.
A simple example that I think many people will find useful is starting up the server, tailing the log and opening the project up in their favorite text editor. Currently, my favorite text editor is Textmate, but I’m transitioning into the wonderful world of MacVim.
window do before { run 'cd ~/Projects/test' } tab "mate .", "passenger start" tab "tail -f log/passenger.3000.log" tab "open http://localhost:3000" end
“But wait, Danish didn’t you read Rails AntiPatterns?! You’re supposed to have tests!” Yes, I know TDD is very important and I’m working on that. A good example of using Terminitor with tests is the Terminitor project itself. Another cool Terminitor feature is the ability to fetch Github Projects. One caveat is that you need to have the github-gem installed. All you have to do then is $ terminitor fetch achiu terminitor
once the repo is cloned terminitor will automatically run the setup block that is in the Termfile for you.
# Terminitor Termfile setup 'bundle install' run 'watchr test.watchr' tab "irb" tab "open 'http://www.github.com/achiu/terminitor/issues'"
As you can see there is a watchr file that we run in one of our tabs so that every time we make a change to any of our files, the test corresponding with it will run and notify us if anything goes wrong.
Now that I’ve highlighted the features of Terminitor that I?ve found most useful, I suggest that you head over to the github page to check it out for yourself and figure out other things you can do with it to make your life easier.
One thing you might enjoy is Termfile, a new project on github that I created. This was inspired by gitignore, a project from Chris Wanstrath (aka defunkt). I know all of you Terminitor users out there have some really cool Termfiles that the rest of us can utilize. I know the rest of you will start creating some really useful ones. So, fork the Termfile project and add your Termfile in the appropriate directory so that others can find and use them for their projects too.
没有评论:
发表评论