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):
#!/bin/sh
# 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 <brendan@kublai.com> (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.
xterm_set_titles
but it is right there. Fabulous. – Amanda Nov 04 '15 at 22:12xterm_set_titles
was a patch for mutt, but 2 years ago they added thets_
options. – Nov 05 '15 at 05:34