4

I've installed tmux on an OS X system with zsh provided by oh-my-zsh.

I usually use quite a number of tmux windows for a whole bunch of ssh sessions, and I like to keep these windows named after the hosts I'm working with so it makes it much easier for me to figure out which window contains what.

I've tried adding configuration lines like set-window-option -g automatic-rename off and set-option -g allow-rename off to my ~/.tmux.conf, however if I start a new tmux session, rename the window and cd into a different directory tmux happily renames the window again to match the current working directory.

How can I name windows without them changing on me automatically?

  • 1
    It should read "set-window-option -g allow-rename off", right? – mpy Apr 24 '14 at 19:17
7

I had similar problem but with byobu-screen and after some research, it turned out that it is oh-my-zsh feature.

This has been discussed on oh-my-zsh issues page

In short, I had to uncomment DISABLE_AUTO_TITLE="true" line in my ~/.zshrc file.

Based on the version of oh-my-zsh, you may have to add export DISABLE_AUTO_TITLE="true".

1

I'm aware that this does not answer you direct question but may help you to get the desired behavior -- and it's too long for a comment

IMHO you should rather cure the cause and not try to ease the symptoms... what I mean is the following: Somewhere in your shell config (probably in one of your activated oh-my-zsh plugins) the window title gets sets every time you change the current dir. Most probably in the precmd() or chpwd() function. So first check the output of

$ which precmd
$ which chpwd

and try to find the source in your zsh rc files.

A workaround can be, to override these functions (with tmux automatic-rename option switched off and allow-rename on):

$ chpwd() { }
$ precmd() {
    if [[ "$TERM" = "screen" ]] && [[ -n "$TMUX" ]]; then
       print -Pn "\033k%m\033\\"
    fi
  }

Remarks:

  • I used the check if you're in a tmux session from that answer
  • The window title is changed via printing an escape sequence everytime before the prompt is redrawn
  • print -P uses the same expansions as in the prompt (see EXPANSION OF PROMPT SEQUENCES in man zshmisc), so %m expands to the hostname up to the first dot.

Be sure, that you insert this code in your ~/.zshrc file after oh-my-zsh gets loaded.

A last point, which comes to my mind: The hostname could only be set by the host you log into. So make sure, that the configuration of all those machines are

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.