Archive for September, 2008

Code Beautifier Textmate Bundle

Thursday, September 25th, 2008

Textmate’s indent functionality does a passable job of formatting your code BUT there is a great deal of room for improvement.

Inspired by the Paul Lutus’s ruby beautifier script and Tim Burks’s post on making it into a Textmate bundle I’ve put together a Code Beautifier Textmate bundle

It only supports Ruby at present but does improve upon Textmate’s indent functionality, in particular it is better at indenting multiline statements and cleans up white space.

It’s all hosted on Github so if you want to make improvements then please fork away.

Installation

Run this:

cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/mocoso/code-beautifier.tmbundle.git Code\ Beautifier.tmbundle

Then select ‘Bundles > Bundle Editor > Reload Bundles’ from Textmate’s menus

Screen Textmate Bundle

Tuesday, September 9th, 2008

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.