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!
Timeline
- Tutorial - Red5, AS3, FC4, and Shared Fridge Magnets!
- Setting up a Flash Media Server on EC2 (CentOS)
- AWS/S3 may cause rake task failed
- Refreshing Rails Generated Views
- Environment Scripts in merb
- Script Terminal with TermInit
- Patching Rails - Rendering form partials
- Open Social plugin progress report
- Notify me when it's done
- OpenSocial on Rails, finally 1.0
- Testing without the database
Comments
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 :)
Simone, glad you found this helpful. The dynamic default is a great idea too!
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.
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).
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.
Thanks for pointing me to this valuable resource. I am going to apply the method Capistrano uses via Net::SSH