iTerm2 Shell Integration and Oh My Zsh Conflicts
I just installed the Shell Integration in iTerm 2 (Build 2.9.20160313) and had the exact same problem.
The way I solved it was by adding a single line to ~/.iterm2_shell_integration.zsh
right after export ITERM_SHELL_INTEGRATION_INSTALLED=Yes
at line 3:
ITERM2_PRECMD_PS1="$PS1"
Thus, this is how the head of the above-mentioned file looks:
if [[ -o login ]]; then
if [ "$TERM" != "screen" -a "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" ]; then
export ITERM_SHELL_INTEGRATION_INSTALLED=Yes
## BEGIN EDIT
ITERM2_PRECMD_PS1="$PS1"
## END EDIT
# Indicates start of command output. Runs just before command executes.
iterm2_before_cmd_executes() {
printf "\033]133;C;\007"
}
# ...
It's likely a bug, since (as you can see from the comments in the same file) the script is supposed to save your $PS1
on login, but it does not.
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