Skip to content

Instantly share code, notes, and snippets.

@victor-torres
Created March 1, 2016 12:51
Show Gist options
  • Save victor-torres/67c272be0cb0d6989729 to your computer and use it in GitHub Desktop.
Save victor-torres/67c272be0cb0d6989729 to your computer and use it in GitHub Desktop.
Uninstalling shell integration from iTerm 2
#!/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."
which sed > /dev/null 2>&1 || die "Shell integration requires the sed binary to be in your path."
SHELL=$(echo "${SHELL}" | tr / "\n" | tail -1)
HOME_PREFIX='${HOME}'
SHELL_AND='&&'
QUOTE=''
if [ "${SHELL}" == tcsh ]
then
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
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
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 "Removing script from ${FILENAME}..."
rm "${FILENAME}" > /dev/null 2>&1 || die "Couldn't remove script from home directory"
echo "Checking if ${SCRIPT} contains iterm2_shell_integration and removing it..."
sed -i -e '/iterm2_shell_integration/d' "${SCRIPT}" > /dev/null 2>&1
echo "Done."
echo ""
echo "The next time you log in, shell integration will be disabled."
@IamSwap
Copy link

IamSwap commented Jul 8, 2016

Thanks 👍

Copy link

ghost commented Jul 15, 2016

Your shell, bash, is not supported yet. Only tcsh, zsh, bash, and fish are supported. Sorry!

@rhukster
Copy link

Saved my bacon! Thanks.

@perariontaeadastra
Copy link

does not work with bash

@mahbuburahman
Copy link

Look in your ~/.profile, ~/.bash_profile, ~/.login, ~/.zshrc, or ~/.config/fish/config.fish (which file it's in depends on what shell you use) for a line like this:

test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

And remove or comment it.

@usherfu
Copy link

usherfu commented Dec 12, 2018

Thanks!

@vickyhoo
Copy link

curl -L https://gist.githubusercontent.com/victor-torres/67c272be0cb0d6989729/raw/31cb1f30fcba4e9853cdc9ad5eda6b181ae59062/uninstall_shell_integration.sh | bash

@aubreypwd
Copy link

aubreypwd commented Jun 20, 2019

Worked great, +1

@Heath101
Copy link

Heath101 commented Oct 8, 2019

thanks!

@akkarapon
Copy link

thanks

@GiorgioBertolotti
Copy link

Works great, thanks!

@TheFe91
Copy link

TheFe91 commented Jul 14, 2020

Thank you, very useful!!!

@faddat
Copy link

faddat commented Nov 15, 2020

bless you, hero

<3

@mrvincenzo
Copy link

👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment