iterm2 and oh-my-zsh: what is overriding the iterm2 title in oh-my-zsh?

188 Views Asked by At

I use oh-my-zsh and iterm2 (on my Macs). The issue is when I ssh from a Mac to another host on which I have an account (usually linux). There I also have oh-my-zsh installed. I have the iterm2 plugin enabled and turned on the iterm2 shell integration according to the iterm2 plugin documentation.

When I run an ssh command to another host, I see the iterm2 tab title change as I would expect (with the name of the remote host) during the ssh connection process, and then once oh-my-zsh is run on the remote host, the prompt is reset to what it was before the ssh connection. I've tried turning off the shell integration / iterm2 plugin on the remote host, to no avail.

How is this supposed to work? All tips appreciated.

edit:

When I ssh into a host for which oh-my-zsh is not installed (for example I ssh into a root account and get bash) then the title works as I expect, so it appears to be some interference between oh-my-zsh settings remote vs local.

1

There are 1 best solutions below

0
Jeff Templon On

I figured it out - maybe this helps someone else.

  1. The iterm2 oh-my-zsh plugin on the remote host is irrelevant - that only does something if the remote host is a Mac.
  2. Locally on the Mac, enable the iterm2 plugin and also use the omz directive to turn on the shell integration as described in the plugin documentation.
  3. On the remote host, download the shell integration script and also include the line to source it as the last line of .zshrc.
  4. Locally on the Mac, go to the iterm2 preferences and look at Profiles-General where under Basics you find a drop-down menu "Title" - select what you want to see here. Play around with the different options and it will soon become apparent what you want to select.

As for me, I have selected what is shown in the attached screenshot.

iterm2 menu screenshot