How to Remove Shell Integration from Iterm2
How to Remove Shell Integration From iterm2 - Tech TLDR;

I tried shell integration for iterm2 and I didn’t like it.



I wasn’t sure how to remove it, so I looked into the install script.


#!/bin/bash

function die() {
  echo "${1}"
  exit 1
}

which printf > /dev/null 2>&1 || die "Shell integration requires the printf binary to be in your path."

SHELL=$(echo "${SHELL}" | tr / "\n" | tail -1)
URL=""
HOME_PREFIX='${HOME}'
SHELL_AND='&&'
QUOTE=''
if [ "${SHELL}" == tcsh ]
then
  URL="https://iterm2.com/misc/tcsh_startup.in"
  SCRIPT="${HOME}/.login"
  QUOTE='"'
fi
if [ "${SHELL}" == zsh ]
then
  URL="https://iterm2.com/misc/zsh_startup.in"
  SCRIPT="${HOME}/.zshrc"
  QUOTE='"'
fi
if [ "${SHELL}" == bash ]
then
  URL="https://iterm2.com/misc/bash_startup.in"
  test -f "${HOME}/.bash_profile" && SCRIPT="${HOME}/.bash_profile" || SCRIPT="${HOME}/.profile"
  QUOTE='"'
fi
if [ `basename "${SHELL}"` == fish ]
then
  echo "Make sure you have fish 2.2 or later. Your version is:"
  fish -v

  URL="https://iterm2.com/misc/fish_startup.in"
  mkdir -p "${HOME}/.config/fish"
  SCRIPT="${HOME}/.config/fish/config.fish"
  HOME_PREFIX='{$HOME}'
  SHELL_AND='; and'
fi
if [ "${URL}" == "" ]
then
  die "Your shell, ${SHELL}, is not supported yet. Only tcsh, zsh, bash, and fish are supported. Sorry!"
  exit 1
fi

FILENAME="${HOME}/.iterm2_shell_integration.${SHELL}"
RELATIVE_FILENAME="${HOME_PREFIX}/.iterm2_shell_integration.${SHELL}"
echo "Downloading script from ${URL} and saving it to ${FILENAME}..."
curl -L "${URL}" > "${FILENAME}" || die "Couldn't download script from ${URL}"
chmod +x "${FILENAME}"
echo "Checking if ${SCRIPT} contains iterm2_shell_integration..."
grep iterm2_shell_integration "${SCRIPT}" > /dev/null 2>&1 || (echo "Appending source command to ${SCRIPT}..."; echo "" >> "${SCRIPT}"; echo "test -e ${QUOTE}${RELATIVE_FILENAME}${QUOTE} ${SHELL_AND} source ${QUOTE}${RELATIVE_FILENAME}${QUOTE}" >> "${SCRIPT}")
echo "Done."
echo ""
echo "The next time you log in, shell integration will be enabled."

Code language: PHP (php)


I am currently using bash, so all they did was to add an entry into my ~/.bash_profile file and download a ~/.iterm2_shell_integration.bash file.



All I had to do, is remove the ~/.iterm2_shell_integration.bash file, and remove this line test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" from my ~/.bash_profile



If you are tech savvy enough to use other shells, you should be able to figure out from the script above what file to remove and which entry to remove from your shell config file.
