Screen Textmate Bundle
When working on a rails project I usually have script/server, script/console and autotest all running in GNU Screen. Jamie Flournoy has already described why using GNU screen is better than plain old Terminal Tabs.
I’ve put together a Screen Textmate Bundle to make it easy to configure and open per project screen sessions.
Installation
Run this:
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/mocoso/screen.tmbundle.git Screen.tmbundle
Set up your screen configuration for a project
Create a .screenrc file in your project directory if you want to specify a particular configuration for your project.
For example for a Ruby on Rails project you might create a .screenrc file in your project directory like this
# Have the server running in screen 1
#
# Stuff is used so that when you exit the stuff-ed program, you drop back
# to the bash shell for that screen instead of immediately exiting that
# screen. This is useful for "^c, up-arrow, enter" restarting of programs.
screen -t server 1
stuff "script/server\012"
# Have autotest running in screen 2
screen -t autotest 2
stuff "autotest\012"
# Have the console running in screen 3
screen -t console 3
stuff "script/console\012"
# Finally have a command line prompt at the project root in screen 4
screen -t project_root 4
Usage
Use this bundle’s ‘Start Session’ command (ctrl-shift-s) to start (or reconnect to) your project’s screen session.
If you have created a .screenrc file in your project directory then this will be used to initialize the new session.
Update (14th Sep 2008)
On Jonathon Palardy’s suggestion I’ve added a ‘Send to Screen’ command (ctrl-alt-c) that copies selected text (or current line if no selection made) to your project’s screen session. If you have multiple windows open in the session then it will paste to the currently selected window.
November 2nd, 2008 at 6:29 am
Very cool - exactly what I was looking for after seeing Rich Hickey’s clojure demo with emacs+slime+swank+clojure.
I now retrospectively resent every cli session that I haven’t been controlling from textmate.
A couple of small points - none of the keyboard shortcuts seem to coincide with what you describe (ctrl-a to start session and ctrl-alt-c to send a command), appending a carriage return makes sending commands a little more convenient and for some reason my .screenrc wasn’t getting picked up (haven’t looked into it).
November 2nd, 2008 at 7:25 am
Glad you like it.
Perhaps they are clashing with another bundle you have. Try changing the keyboard shortcuts using Textmate’s Command Editor (look in Bundles -> Bundle Editor -> Edit Commands menu) and see if that helps.
Also this will either use a .screenrc in your project folder (if there is one) OR your .screenrc in your homefolder. Which one of these is not being picked up when you expect it to be?