With the help of Display command in xterm titlebar I've got gnome-terminal changing the title to reflect the running command, so that I can see which terminal Mutt is running it. But what I'd really like is to push my Mutt status up to the title. I have this in my .muttrc:

set status_format = "%n new | %M in %f [%v]."

and I'd love to push that whole status to my gnome-terminal title. Is there a way to do that in my .bashrc? Or another way?

There's a discussion of how to do this from w/in vim at http://vim.wikia.com/wiki/Automatically_set_screen_title but...that's vim.

2 Answers 2


mutt can already do this.

man muttrc

          Type: boolean
          Default: no

         Controls whether mutt tries to set the terminal status line and
          icon name.  Most terminal emulators emulate the status line in
          the window title.

          Type: string
          Default: “Mutt with %?m?%m messages&no messages?%?n? [%n NEW]?”

         Controls the format of the terminal status line (or window
          title), provided that “$ts_enabled” has been set. This string is
          identical in formatting to the one used by “$status_format”.

Unfortunately it doesn't change the title back, when you exit mutt.

  • Huh. Maybe a version thing. For me it's xterm_set_titles but it is right there. Fabulous.
    – Amanda
    Nov 4, 2015 at 22:12
  • I believe that xterm_set_titles was a patch for mutt, but 2 years ago they added the ts_ options.
    – user90883
    Nov 5, 2015 at 5:34

It is possible to make the status_format run an external script which can set the title. This was described on the mutt mailing list several years ago by Amit Ramon, using a pipe symbol |, which is documented as:

Any format string ending in a vertical bar (“|”) will be expanded and piped through the first word in the string, using spaces as separator. The string returned will be used for display. If the returned string ends in %, it will be passed through the formatter a second time. This allows the filter to generate a replacement format string including % expandos.

Ramon's example was this string:

set status_format="mutt_status \"$my_status\" \"$my_title\"|"

In his example, mutt_status is a simple shell script which echos the first parameter to the standard output (and is displayed in the status line), while the second is written to the /dev/tty device (and is displayed in the xterm title bar):


# Demonstration of format string pipes. Sets the xterm title to the 2nd argument,

# and returns the first  unchanged.
# this sets the title
printf "\033]0;$2\007" > /dev/tty
echo "$1"
# end of script

Ramon's note said that $my_status and $my_title are variables which he defined in his configuration (but gave no specifics beyond pointing to the Mutt documentation for status_format.

For your example,

set status_format = "mutt_status \"%n new | %M in %f [%v].\" \"%n new | %M in %f [%v].\"|"

would send the same information to both status- and title-lines.

In reviewing this, I did not notice ts_enabled and ts_status_format, which @Thomas Weinbrenner describes. That was added to mutt just a few months ago, in August 2015:

    1.5.24 (2015-08-31):

      + terminal status-line (TS) support, a.k.a. xterm title. see the
        following variables: $ts_enabled, $ts_icon_format, $ts_status_format

That feature uses the terminfo feature tsl, which according to terminfo(5) requires a parameter:

   to_status_line            tsl    ts   move to status line,
                                         column #1

However, the title-string for xterm does not accept a parameter. It is largely ignored in ncurses as such for this reason, although there is (for the sake of discussion) an xterm+sl entry first added in 1999. You will not find that used in the "xterm" terminfo. Rather, the extension TS has been the recommended alternative since 2012.

Except for xterm, restoring the title after exit from mutt has not been widely supported for several years, due to concerns about malformed escape sequences. xterm provides a query/response which is disabled by default in most packages. Also, it provides another control sequence which makes title strings stacked. GNU screen uses this feature (added November 2009); for most other applications the (mis)use of tsl / fsl is too firmly entrenched to make any difference to the typical user.

This question appears to be a reposting from LQ early in 2015, which interestingly enough points to an older mutt release announcement:

Mutt 1.5.15 was released on April 6, 2007. This version has several new and long-standing feature patches applied in anticipation of a feature freeze toward 1.6. These include built-in SMTP, flowed mail support improvements, xterm title updating, charset improvements, GPG PKA support, etc. See the ChangeLog for full details.

However, that appears to refer to a patch:

2007-03-14 14:45 -0700  Brendan Cully  <[email protected]>  (35b8facdbdda)

    * contrib/Makefile.am, contrib/mutt_xtitle, muttlib.c: Add demo
    mutt_xtitle script

which I already knew about from earlier discussion (and ignored because it was not incorporated into mutt itself). Some packagers may have applied this patch, but the feature was renamed when it was finally (about more than ten years) incorporated into mutt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .