alexkras.com

  • Home
  • Top Posts
  • Resume
  • Projects
  • YouTube
  • Boots to Bytes
  • About
  • Contact

How to Remove Shell Integration From iterm2

July 13, 2016 by Alex Kras 4 Comments

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."

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.

Filed Under: Tools

I work for Evernote and we are hiring!

Subscribe to this Blog via Email

New posts only. No other messages will be sent.

You can find me on LinkedIn, GitHub, Twitter or Facebook.

This blog is moving to techtldr.com

Comments

    Leave a Reply Cancel reply

  1. RD says

    February 6, 2020 at 11:04 am

    Thank you for your help! I did not have this file ~/.bash_profile but removing ~/.iterm2_shell_integration.bash file helped.

    Reply
  2. vigneshrajarr says

    May 24, 2018 at 8:59 am

    Thanks for helping to me to remove the integration.

    Reply
  3. Paul says

    November 24, 2017 at 1:18 am

    I just came across your post. Is there a benefit to installing shell integration for iTerm2? Aside from basically tracking commands, I’m not that sure what the benefit is?

    Reply
    • Alex Kras says

      November 24, 2017 at 5:53 pm

      I didn’t see any.

      Reply

Copyright © 2021 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in