7

In TextMate 2, when you have multiple documents open at once, and they appear in a row of tabs on the main window, is there a way to change the text (filename) shown in each tab?

By default, it shows the file's basename (the filename without any path information). I don't want full path information displayed on each tab, but I would love to have the file's current_directory/filename on each tab.

(In .tm_properties, I did set windowTitle = $TM_FILEPATH to show the full filepath at the top of the main window, so I at least have that.)

To illustrate what I'm asking, if I have a set of files open as such:

  • /Users/me/projects/code/lib/Shapes.pm
  • /Users/me/projects/tmp/Shapes.pm
  • /Users/me/projects/var/data/Shapes.pm

This is what the tabs currently look like:

Shapes.pm | Shapes.pm | Shapes.pm

What I would prefer is to see is:

lib/Shapes.pm | tmp/Shapes.pm | data/Shapes.pm

i.e., each file's current directory prepended to the filename itself. A Perl regex would make easy work of getting that. Does TextMate 2 give you the ability to modify the "tab title" per above? Thanks!

user3112401
  • 373
  • 2
  • 9

1 Answers1

8

Since TextMate v2.0-rc.8 (2018-03-08, installable when enabling "nightly builds") the tab title can be configured in the same manner you would do with the window title.

For example, the following configuration would give you the filename, prefixed with the name of the immediate parent directory.

tabTitle = "${TM_DIRECTORY/^(.*[\/])//}/$TM_DISPLAYNAME"

tabs

Koen.
  • 25,449
  • 7
  • 83
  • 78
  • 1
    Finally! Thanks! I'll note that you must have your update preferences set to "nightly builds" in order to see this version during check for updates. – user3112401 May 28 '18 at 14:41
  • 1
    Works like a charm in TM 2.0.15. For everyone wondering where to put it: TextMate -> Preferences -> Variables tab -> click [+]. Value should be added without quotes. – Pawel Pabian bbkr Sep 22 '20 at 12:40
  • @PawelPabianbbkr my example is actually referring to the `.tm_properties` file, but good to know that it works from there as well. – Koen. Sep 25 '20 at 07:58