Fix terminal /bin/zsh does not work in IntelliJ IDEA v2018.3.1 macOS

Nhan Cao
1 min readDec 6, 2018

In the terminal point to /bin/zsh, but seem the PATH in IDEA is not correct with global which defines in .zshrc and .bash_profile

The reason is

Look at the original /Applications/IntelliJ\ IDEA.app/Contents/plugins/terminal/.zshrc

function override_jb_variables {
for VARIABLE in $(env)
do
NAME=${VARIABLE%%=*}
if [[ $NAME = '_INTELLIJ_FORCE_SET_'* ]]
then
NEW_NAME=${NAME:20}
if [ -n "$NEW_NAME" ]
then
VALUE=${VARIABLE#*=}
export "$NEW_NAME"="$VALUE"
fi
fi
done
}
override_jb_variables

In the script, at the if condition, the default env of JetBrains is _INTELLIJ_FORCE_SET_PATH, so that the NEW_NAME variable will be PATH then assign to idea path and it’s not a system path which defines in .zshrc and .bash_profile.
To fix this, edit the condition to skip with NEW_NAME=“PATH”, look like

function override_jb_variables {
for VARIABLE in $(env)
do
NAME=${VARIABLE%%=*}
if [[ $NAME = '_INTELLIJ_FORCE_SET_'* ]]
then
NEW_NAME=${NAME:20}
if [ -n "$NEW_NAME" ] && [ "$NEW_NAME" != "PATH" ]
then
VALUE=${VARIABLE#*=}
export "$NEW_NAME"="$VALUE"
fi
fi
done
}

--

--

Responses (2)