6

While using byobu, my terminal tab's title is set to user@fqdn (IP) - byobu, which can be pretty long depending on the domain. How can I limit it to something shorter, like user@hostname, or better yet, let zsh set the title? I have tried setting BYOBU_NO_TITLE=1, following this bug, but that, I think, allows the local shell to set the title, not the remote one.

This can be very annoying, since Terminator sets every tab header's length to the same, so one very long title is enough to make all of them very long. Worst case, I'd like it if I could simply trim off some of it to a maximum length (like user@f ... byobu).

I already have added a function to .zshrc to set the title:

case $TERM in
    xterm*|screen*)
        if [[ -n $SSH_TTY ]]
        then
            precmd () {print -Pn "\e]0;%m: %~\a"}
        else
            precmd () {print -Pn "\e]0;%~\a"}
        fi
        ;;
esac

This works if I don't use byobu:

enter image description here

The tab on the left is an SSH session without byobu, and the one on the right is with byobu.

With Serg's suggestion of setting IP_EXTERNAL to 1, I can get rid of the IP, shortening the title. I'd prefer a solution that passes on the title set by zsh (or other applications, such as Vim) to the terminal - it looks like byobu/tmux blocks them.

muru
  • 197,895
  • 55
  • 485
  • 740

2 Answers2

4

UPDATE: April 10, 2015

My current solution that does not depend on the use of shell or terminal is to use wmctrl from a script, and place full path to the script in .byoburc . Works with gnome-terminal, terminator, sakura - just about any termimal Here's the script:

#!/bin/bash
# Description: byobu always has string ") - byobu" in it's window title
# like user@hostname (192.168.0.2) - byobu
# So why not find windows with exact same string, and tell wmctrl to
# set the title for us ? That's all we do here

BYOBU_WINDOW=$( wmctrl -lx | awk '/) - byobu/ {print $1}' )
sleep 0.5
wmctrl -ir $BYOBU_WINDOW -N "MYTITLEHERE"

Original post

As far as gnome-terminal goes, you can set profile preferences to keep the initial title specified in the profile settings. Bellow is the screenshot of my byuobu with keep the initial title option, and with replace initial title option

screenshot 1

enter image description here

As for Terminator, I'll download and see if same applies to it.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • 1
    Perhaps I should have been clearer. I want the title to be set by the shell (and or other running programs), so that option is of no use. BYOBU_NO_TITLE is a simpler way of disabling byobu's title setting altogether. – muru Apr 09 '15 at 08:05
  • 1
    So you'd want something like .byoburc or .zshrc setting the title , is that right ? regardless of the terminal ? – Sergiy Kolodyazhnyy Apr 09 '15 at 08:08
  • 1
    The only ting I've found so far is IP_EXTERNAL in .byobu/statusrc file, which if i set to IP_EXTERNAL=1 cuts out my machine's ip address, so it makes the title shorter, consisting only username@host () - byobu – Sergiy Kolodyazhnyy Apr 09 '15 at 08:12
  • @muru found a solution that doesn't depend on shell or terminal, please refer to the updates above. Tested with 3 different terminals. Let me know what you think – Sergiy Kolodyazhnyy Apr 11 '15 at 05:54
  • sorry, but this looks like it has to be done on the local system, right? If that's the case, setting BYOBU_NO_TITLE=1 lets the local shell set the title anyway. The problem is letting the remote application (shell or otherwise) set the title (which it tries to). Zhongfu's comments indicate that it is tmux that's causing the problem. – muru Apr 11 '15 at 06:01
  • Basically,yes. This solution depends on presence of wmctrl on your local system. Speaking of tmux, when you use byobu with tmux, env | grep TMUX gives that there are two environmental variables set. Could we try testing if those variables are set (in addition to $TERM ), and if they are, change the title ? – Sergiy Kolodyazhnyy Apr 11 '15 at 06:16
1

i have found that byobu uses tmux in the back end. and tmux does have some ways to set the terminal title with the following lines in .byoubu/.tmux.conf:

set -g set-titles on
set -g set-titles-string "#(pwd)"

where #(pwd) sets it to the working directory the range of options can be found in the man page of tmux under the formats section

digging a little deeper it seems that byobu by default comments exactly these two lines out in /usr/share/byobu/profiles/tmux to set its own custom title

Fuseteam
  • 383