TextMate shell utility (tm/mate)

Included with previous versions of TextMate was a shell command named tm which is absent from the recent update (for those who don’t read the release notes).

The command is now located in the actual TextMate application bundle (under Contents/Resources), and is named mate (since some mistyped tm and got rm instead).

What you are supposed to do is, create a symbolic link from your bin directory to the shell command inside the application bundle. So assuming you installed TextMate under /Applications and you want the mate command in ~/bin, you would (from Terminal) run:

ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate

Since this only creates a symbolic link, updating TextMate in the future should keep the shell command up-to-date as well.

I plan to allow TextMate to create this symbolic link for you, just need to figure out the best way to do so.

On the subject of the mate shell command, setting your path to include ~/bin needs (for bash) to be done like this:

export PATH="$HOME/bin:$PATH" 

It is important that you use $HOME instead of ~, since the tilde is not expanded inside strings (the line should be placed in e.g. ~/.bash_profile).

One purpose of the mate command is so that you can use TextMate as your editor for Subversion commit messages and similar (for the few times you do not commit from within TextMate :) ), for this to work, mate should be called with the -w option, and for most applications you can include that in the EDITOR variable, e.g.:

export EDITOR="$HOME/bin/mate -w" 

There is one command though, which doesn’t support that. It is crontab, and in this case you can either do a wrapper (script) for mate which adds the -w argument (that is what the previously included tm_wait script did), or you can create another symbolic link to the mate executable, which has _wait as suffix, e.g.:

ln -s mate ~/bin/mate_wait

When the shell command is called with that suffix, it will automatically set the -w flag.

If you do not plan to use crontab (which I guess is obsolete now that we have launchd), you can ignore all this.

17 Comments

  1. 06 Oct 2005 | # topfunky wrote…

    That is awesome! I love the svn integration.

    TextMate keeps improving. Next, will it do my taxes and pay my bills automatically for me?

  2. 06 Oct 2005 | # Anonymous wrote…

    why are my macros not working as they did before. instead of adding html tags before and after a line of text its now replacing that text

  3. 07 Oct 2005 | # Allan Odgaard wrote…

    Anonymous: go to ~/Library/Application Support/TextMate/Bundles and do Show Package Contents on the HTML bundle, in the Macros folder (inside the bundle) there's the “Start:end tag from previous word” macro which you should delete.

    Since the regexp library was updated, the macro needed updating as well, but if you have changed some aspect of it, it will be (in the changed form) stored in ~/Library and take precedence over the (now updated) default version.

  4. 07 Oct 2005 | # JBrickley wrote…

    Allan, what about the TextMate Service? I notice it's not included in the latest release. I like what you did with the tm to mate change and bundling it into the .app bundle. Can you put the Service in there as well? You could automate both the mate link and copying the Service.

  5. 07 Oct 2005 | # Allan Odgaard wrote…

    JBrickley: yes, I want to put the service in the bundle as well. As for autmating creation of the symbolic link, there's a small thread about it on the mailing list, with peoples miscellaneous preferences to location :)

  6. 11 Oct 2005 | # pfig wrote…

    as a former bofh, i fail to see why you replaced tm g

  7. 11 Oct 2005 | # Michael J. Cohen wrote…

    TextMate is lovely!

    As soon as I have enough spare cash, I'll certainly buy a copy.

    I'd like to suggest Windows NT command file support (.CMD) though, I think it'd be a wonderful addition.

  8. 12 Oct 2005 | # JBrickley wrote…

    Dang it, now I am confusing mate with make! ;-)

  9. 12 Oct 2005 | # Allan Odgaard wrote…

    Michael: What are .CMD files, and what would TM do with them?

  10. 13 Oct 2005 | # john joseph bachir wrote…

    hi, this is OT but i couldn't find a more appropriate channel for my question: where/how do i report textmate bugs? none of the wiki pages seemed appropriate. sorry if i am missing something obvious.

    thanks for a great product! john

  11. 13 Oct 2005 | # john joseph bachir wrote…

    oh dear, i just saw the bugs email address in the side panel… carry on…

  12. 13 Oct 2005 | # Pete Lasko wrote…

    When you have enough cash?? Its only like $50.

    I love what you're doing with TextMate. There is so much here, its amazing how quickly you've been able to o it all.

  13. 02 Nov 2005 | # Gromski wrote…

    If, like me, you moved TextMate.app after opening it for the first time, the tm/'mate' command won't work from Terminal anymore.

    I tried recreating it from the command line but for some reason I just couldn't get it to work.

    The solution is to get TM to create the link for you again. Just delete your com.macromates.textmate.plist from /Users/YOURUSERNAME/Library/Preferences and the next time you start TM it'll ask you whether you want to create the link again.

    If you've got a custom theme saved then you should be able to just open the theme file and TM will pick up your prefs again.

    Only been playing with it for a day but TM is absolutely great…goodbye BB :)

  14. 03 Nov 2005 | # Allan Odgaard wrote…

    Gromski: Glad you like it!

    As for re-creating the link, you can get the wizard again using the Help → Terminal Usage… menu action :)

    In the future though, I'll detect when TextMate is launched from a new location, and update the link accordingly.

  15. 16 Dec 2005 | # Jeroen wrote…

    There is an Ruby on Rails video " 15 minutes weblog ". And there he uses the command 'e .' to start textmate with te current directory as project.

    Anyone got that command tool ??? I want it!! :D

  16. 16 Dec 2005 | # Allan Odgaard wrote…

    The mate command can do that (alias it to e), although I'm quite sure DHH actully just has this in his ~/.bash_profile:

    alias e="open -a TextMate"

  17. 27 Jan 2006 | # Andrey Nikanorov wrote…

    I use this in ~/.profile: alias mated="mate *"

Comments closed, you can use the mailing list for discussion.