Home » Questions » Computers [ Ask a new question ]

How do I set the title of Terminal.app with the fish shell?

How do I set the title of Terminal.app with the fish shell?

I'm trying the fish shell in Mac OS X, intalled using MacPorts. I'd like to have the title of my Terminal window be my current directory. Currently, the title just says

Asked by: Guest | Views: 362
Total answers/comments: 2
bert [Entry]

"I installed fish (1.23.1) to investigate this. It turns out that fish only updates the title if $TERM is one of the following: xterm, screen, nxterm, rxvt. Otherwise, it never calls the fish_title function.

Terminal's default value is xterm-256color and prior to Mac OS X Lion 10.7 it was xterm-color, neither of which is recognized by fish. Fish is simply being unreasonably conservative about which terminfo values it thinks support this feature. fish_title isn't called for any xterm* variants, for example.

To work around this limitation of fish, you can set $TERM to xterm. The simplest way to do this is with a Terminal preference setting:

Terminal > Preferences > Settings > [profile] > Advanced > Declare terminal as

Select xterm from the popup menu. This preference controls the value of $TERM (that's all it does).

Note that using xterm instead of Terminal's default may disable some terminal functionality or, prior to Lion, cause misbehavior due to incompatibilities between the xterm terminfo description and older versions of Terminal.

Therefore, if fish isn't your default shell, you may want to only change $TERM when invoking fish. e.g., you can invoke fish with TERM=xterm fish from a shell, or you can create a custom Terminal settings profile just for running fish (you can set the ""Run command"" preference to invoke fish, so creating a new terminal window or tab with this profile will automatically run fish).

Or, if you're not shy about modifying fish: once you've installed it via MacPorts or Fink you've got the sources sitting on your machine and you can extend its list of recognized $TERM values, or even update the code to allow for suffixes on the recognized values. e.g., it should at least allow any values that start with xterm or screen. Otherwise, it's not even going to work with common screen variants. And if you do that, please contribute it back to the fish project."
bert [Entry]

"It is likely something to do with the configuration of Terminal.app. I'm running Terminal 2.0.2 on Leopard which allows me to configure the window's title via the preferences (see settings -> window).

It's possible that enabling 'shell command name' might get your desired result. The default is just to display Terminal - $process - $size probably over-rules the fish environment."