Quickly Copy Current File Path in TextMate

by serge on August 6th, 2010

I work with remote teams most of the time. And wile I do respect co-location practices, from my experience a phone and an instant messenger together can serve as a pretty good communication channel as well. Given this, I often need to get someone’s attention to a particular piece of code, so that we’re looking at the same file in order to discuss it. One way to achieve that is to paste file path into a chat room. But in order to paste, I need to get that path into the clipboard first. There are some some things like this that we just have to accept.

I’ve found this beautiful article on the topic. It has nice explanation of different ways to access current file location in TextMate. I’ve chosen the last option for myself and created a custom bundle, but did a small change in script however. Having file path relative to the file’s project directory is more convenient for me, I don’t want to distract people with details of my home folder organization. Here’s my version of the script:

echo -n "$FILEPATH" | pbcopy && echo "Path copied to clipboard: $FILEPATH"

You can create it yourself using CiarĂ¡n’s guide and this code snippet, or just grab it from github: http://github.com/bgipsy/files-tmbundle

Comments are closed for this entry.