Ubuntu – How to modify the terminal title set by byobu


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
        if [[ -n $SSH_TTY ]]
            precmd () {print -Pn "\e]0;%m: %~\a"}
            precmd () {print -Pn "\e]0;%~\a"}

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.

Best Answer

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:

# Description: byobu always has string ") - byobu" in it's window title
# like user@hostname ( - 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

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.