Blog

Jan
16
Script Terminal with TermInit
by ELC | Snippet

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!

6 Comments
January 29, 2009

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 :)

January 29, 2009

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

Nathan
January 29, 2009

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.

January 29, 2009

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
January 29, 2009

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.

January 29, 2009

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