• Posted by Peter Haza
  • On September 8, 2008

  • Filed under TextMate

  • No Comments

TextMate tip: Open in Finder

If you like working with your documents on the command line, I’m sure you’ve learned to love ⌃⇧O. This will open a new terminal window in the current document’s folder, ready for you to pull out your terminal-fu. Sometimes, however, you’d like to reveal the file in the Finder. I got this very simple script from Malesca

  1. Create a new command
  2. Save → Current file
  3. Key equivalent → ⌃⇧O
  4. Input → None
  5. Output → Discard
The command itself is as easy as this:

if [[ -d $TM_SELECTED_FILE ]]; then
TM_PATH="$TM_SELECTED_FILE"
elif [[ -f $TM_SELECTED_FILE ]]; then
TM_PATH="`dirname "$TM_SELECTED_FILE"`"
else
TM_PATH="`dirname "$TM_FILEPATH"`"
fi

open "$TM_PATH"

Now if you press ⌃⇧O you’ll be prompted to open in Terminal or open in Finder.

Make sure you check out my other TextMate tips, and don’t forget to visit Malesca and check out his TextMate tips too.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

What do you think? Join the discussion...