Skip to content

Instantly share code, notes, and snippets.

@unicornrainbow
Created January 15, 2011 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicornrainbow/780553 to your computer and use it in GitHub Desktop.
Save unicornrainbow/780553 to your computer and use it in GitHub Desktop.
A bash function which improves the textmate mate command by opening a project file if available.
# Description:
# Changes the functionality of `mate` and `mate .` to open
# a textmate project file named after the current directory if one
# exists.
#
# What advantages do project files have?
# - If the project is already open, the window will be reused rather then creating another
# one. This creates a presents a nice way to focus on the project from the command line.
# Just type mate (or mate . if your in the habit.)
# - Projects remember what files you had open last time so they're great for jumping back
# in from where you left off.
# - With projects you can customize how the directory tree is displayed in the project panel.
# I add only the folder I use frequently and ignore the rest.
#
# Usage:
# First, you'll need a project file for this command to help. To create one, run mate . from
# this will open textmate with the entire directory strutue in the project panel. from the
# textmate menu select File > Save Project and click save. Note that the project
# name should match that of the containing folder.
function mate(){
local proj=$(basename `pwd`).tmproj
if [ $# -eq 0 ]; then
if [ -f $proj ]; then
open $proj
else
command mate
fi
else
if [ "$@" = '.' -a -f $proj ]; then
open $proj
else
command mate "$@"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment