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.
printf '\e]2;Custom Window Title\a'
Does that work in fish?