iTerm2 Shell Integration affects CodeRunner
I use an application called CodeRunner for quick editing and execution of scripts (mostly testing).
Installing iterm shell integration adds a test command to .bash_profile.
test -e ${HOME}/.iterm2_shell_integration.bash && source ${HOME}/.iterm2_shell_integration.bash
This causes unexpected output when running anything bash related in CodeRunner.
Example:
#!/bin/bash
echo $ITERM_SESSION_ID
Output:
]1337;RemoteHost=myuser@myuser-mbp.mydomain.com]1337;CurrentDir=/Users/myuser]1337;ShellIntegrationVersion=1
This was easily resolved by wrapping the test in an if block that evaluates $ITERM_SESSION_ID.
if [ ! -z "$ITERM_SESSION_ID" ]
then test -e ${HOME}/.iterm2_shell_integration.bash && source ${HOME}/.iterm2_shell_integration.bash
fi
This allows iTerm to still source iterm2_shell_integration while not sourcing it for other apps.