1. Skip to navigation
  2. Skip to content

The ELC Community Blog

A knowledge exchange on Ruby on Rails and Agile Development


Script Terminal with TermInit

by Jeff Emminger on January 16, 2008

Are you tired of typing the same commands in Terminal every day just to get your project going? Do you want to save, like *minutes* per day? Did you know that you only get so many keystrokes per lifetime before your hands are permanently crippled? OK, that last bit I might have just read somewhere but I digress.

Enter TermInit, stolen^H^H^H^H^H^H inspired by Solomon White's work here: http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal

...and all packaged up for easy use: https://wush.net/svn/public/terminit/

An example from the readme:

  # myproject.yml:
  - tab1: cd /foo/bar
  - tab2: 
    - mysql -u root
    - use foo_db
    - select * from bar;
  - tab3: echo "hello world"

Open Terminal and run it:

terminit.rb myproject

Et voila, you have three tabs opened in Terminal with the appropriate commands executed in each.

Save those keystrokes for real code!

Comments

Simone Dall'Angelo at 10:47 AM on January 17 2008

I tryed it and it’s so confortable! When I work on a web-app (using rails) i usually have the same tabs (with different paths). To not create a single configuration file for each project i added support for ‘default.yml’ which contains the ‘common’ tabs i need. If i execute ‘terminit foo’ it looks for foo.yml, if it doesn’t exist it loads default.yml using ‘foo’ like a parameter. In default.yml i have something like:

cd /my-apps/[APP]

In this example ‘cd /my-apps/[APP]’ will be changed into ‘cd /my-apps/foo’.

So i have just default.yml for all my web-apps, but if i need more customization i can create foo.yml.

Great job, i’ll use it everydayyyyy :)

Jeff at 4:47 PM on January 17 2008

Simone, glad you found this helpful. The dynamic default is a great idea too!

Nathan at 9:50 AM on January 18 2008

Is there anyway to get this to work with entering passwords.

What I want to do is:

- ssh place@server.com - mypassword - cd /var/path/now

how do I get this to work?

Other than that, this is a great little tool and I love even more that it is done with ruby and yaml.

Jeff at 11:44 PM on January 18 2008

Nathan, Good question. I imagine the method Capistrano uses would work (via Net::SSH), or perhaps a public key and ssh-agent. I haven’t tried either though (yet).

Nathan at 3:38 AM on January 19 2008

Yea, it would be really cool if that could be somehow built into this terminit thing if you ever feel the need. Anyways thanks for making this as its really handy.

Stop at 7:23 AM on January 20 2008

Thanks for pointing me to this valuable resource. I am going to apply the method Capistrano uses via Net::SSH

Add a comment


home | services | Ruby on Rails Development | code | blog | company