Dynamic Tmux Window Titles with SSH and Hostname


Want your Tmux window titles to automatically show the hostname you connect to via SSH — and restore the local name after you disconnect? This guide will walk you through setting that up step by step.

1. Tmux configuration – ~/.tmux.conf

In your Tmux configuration file, set the default shell command to a custom Bash init file (.bash_tmux) that will handle window title updates.

2. Bash init script – ~/.bash_tmux

This file runs at shell startup inside Tmux. It sets the window name to your local hostname and overrides the ssh command to change the window title dynamically.

3. Reload Tmux config without restarting

To apply the changes without restarting the Tmux session, run the following:

To manually reload the current shell with the new .bash_tmux configuration:

4. Final result

  • New Tmux windows automatically show the local hostname
  • When connecting via SSH, the window is renamed to the remote host
  • When disconnecting, the original local name is restored

Clean, readable, and perfect for sysadmins, devops engineers, and Tmux lovers who appreciate automatic order in their terminal tabs 💪