When I SSH into a different box, the username, hostname and directory in the terminal title get updated accordingly, which is great for keeping track of what each session is doing and where. However, I typically directly start tmux when SSHing, i.e. ssh -t box "tmux attach", in which case none of the updates happen. If I first SSH into a shell and only then start tmux, the directory also stops updating when I cd somewhere else. Is there anything I can do to keep the updating behavior?
I've read about Triggers and Automatic Profile Switching, but I can't seem to get Triggers to work inside tmux either. Also, Triggers aren't as clean as the solution that works out of the box outside tmux because echoing foo@bar into the terminal would mess with the username and hostname.
As an aside, let me compliment you on how visually pleasing, well-designed and feature-complete tilix is :) I have been a fairly happy user of guake previously, but tilix is in a whole different league (also compared to terminator, which is featureful but has always felt clunky to me, unlike tilix).
The title and directory changes are driven by /etc/profile.d/vte.sh and it works the same for both gnome-terminal and tilix since tilix is using the same terminal emulator widget (VTE). When you SSH to another system, that system also has to have vte.sh sourced in order for this to work. In your case it sounds like it does since it works outside of tmux.
Do you get the same behavior in gnome-terminal, if so it may be an issue with tmux.
I'm not a tmux user so I haven't tested tilix with it extensively, however note that tilix turns off triggers whenever you go into alternate mode (i.e. run vi, nano, etc). I suspect tmux also runs in alternate mode and thus triggers are disabled.
Do you get the same behavior in gnome-terminal
Yes.
At one point I thought vte.sh might not be getting sourced because tmux doesn't spawn login shells, but turns out it does.
Additionally, if I spell out the entire SSH command, ssh -t remote-box "tmux new -AD -s default", I get at least the name of the remote server in the terminal title, local-user@local-box: remote-box. That would be convenient enough for distinguishing the sessions, but unfortunately, I've got the command wrapped in a function to save on typing:
tth () {
ssh -t $@ "tmux new -AD -s default"
}
And running tth remote-box results in a title which just says local-user@local-box: tth, which isn't very informative. I'll have a look at vte.sh to see if there may be some tweaks to get VTE to recognize my custom tth command.
I suspect tmux also runs in alternate mode and thus triggers are disabled.
Yes, that sounds likely.
If you have the same issue in gnome-terminal then it looks like an issue with VTE. You can open an issue for it at the gnome bugzilla if you wish. As a result I'm going to close this issue.
Yes, thanks for your help :) I'll think about submitting a Gnome Bugzilla issue, but it's starting to look more like a feature request than a bug report, so I'm not really sure if there's any point in trying, Gnome devs are busy as it is.
So, happy to report it ultimately turns out that all you need to do in order to get this to work is to properly configure tmux 馃槄 It took me a while digging around in vte source code to realize that it uses a standard way of setting the title via escape codes which applies to all xterms (and which I didn't even know existed). And luckily, tmux can be configured to send these out. So without further ado, here's what to put in your ~/.tmux.conf, for posterity's sake ;)
# makes tmux send out the proper escape codes for setting the terminal title
set-option -g set-titles on
# sets the content of the title: user@host: /current/working/directory
set-option -g set-titles-string "#(echo $USER)@#H: #{pane_current_path}"
Maybe worth putting in the wiki? Though not tilix-specific, I think some tilix users might find it helpful. Just a thought.
So, happy to report it ultimately turns out that all you need to do in order to get this to work is to properly configure tmux 馃槄 It took me a while digging around in vte source code to realize that it uses a standard way of setting the title via escape codes which applies to all xterms (and which I didn't even know existed). And luckily, tmux can be configured to send these out. So without further ado, here's what to put in your
~/.tmux.conf, for posterity's sake ;)# makes tmux send out the proper escape codes for setting the terminal title set-option -g set-titles on # sets the content of the title: user@host: /current/working/directory set-option -g set-titles-string "#(echo $USER)@#H: #{pane_current_path}"Maybe worth putting in the wiki? Though not tilix-specific, I think some tilix users might find it helpful. Just a thought.
OMG THANK YOU!!!!!!!! This exactly what i was looking for. U DA MAN!
Most helpful comment
So, happy to report it ultimately turns out that all you need to do in order to get this to work is to properly configure tmux 馃槄 It took me a while digging around in vte source code to realize that it uses a standard way of setting the title via escape codes which applies to all xterms (and which I didn't even know existed). And luckily, tmux can be configured to send these out. So without further ado, here's what to put in your
~/.tmux.conf, for posterity's sake ;)Maybe worth putting in the wiki? Though not tilix-specific, I think some tilix users might find it helpful. Just a thought.