ITerm2 Shell Integration and Oh My Zsh Conflicts

iterm2oh-my-zshshell

I've recently re-installed iTerm2 and am now running into an interesting problem after setting up iTerm's Shell Integration.

Upon open a new terminal window, everything seems to look correct, showing the proper "agnoster" theme from Oh My ZSH:

working

If I issue clear, now my terminal window looks like this:

not working

I can revert things to the original state by sourcing ~/.zshrc once again, but I'm really curious about the root issue and if there's any way to fix it.

I have tried hiding the marker in iTerm's settings, but that just results in a blank terminal.

In a previous install (before I wiped this Mac), I had Oh My ZSH and Shell Integration both going, and although it looked kind of wonky at times, it still seemed to keep the Oh My ZSH theme regardless of clearing the terminal or issuing any other command.

Does anyone have any ideas on this? I've checked the iTerm settings over and over, but can't seem to find anything that would be related.

Best Answer

Late answer but this worked for me.

The iTerm2 Shell Integrations page has you download the install script and pipe it into bash.

Instead, download it locally and modify it so it knows you are using ZSH.

First, download the script

wget https://iterm2.com/misc/install_shell_integration.sh

Then, instead of having the script determine the shell just define it as "zsh"

# comment out this line
# SHELL=$(echo "${SHELL}" | tr / "\n" | tail -1)

# replace it with this line
SHELL="zsh"

Next, make the install script executable and then run it

chmod +x install_shell_integration.sh
./install_shell_integration.sh

After that the integration should be installed properly.

Note Remove the Bash integration if you don't need it.

rm ~/.iterm2_shell_integration.bash