Fish terminal + iTerm, only run shell integration if terminal is iTerm

fishiterm2

iTerm has a shell integration script that enables some fancy features, as in having the ability to scroll up to last prompt (in case if there was a lot of stdout i.e. when compiling some code).
However if the terminal is not iTerm, that shell script fails and pollutes the prompt.

I'm trying to clean it up as in only run the shell integration if the terminal is iTerm.

Best Answer

Putting this in your ~/.config/fish/config.fish should do the trick

if test $TERM_PROGRAM = iTerm.app
    test -e {$HOME}/.iterm2_shell_integration.fish ; and source {$HOME}/.iterm2_shell_integration.fish
end
Related Question