As far as Visual Studio Code goes, there apparently is a way to set additional environment variables for the integrated terminal. So, set up Visual Studio to use this config:
"terminal.integrated.env.linux": {
"visual_studio": "true"
}
And within ~/.bashrc
:
if [ -n "$visual_studio" ]; then
# do something for Visual Studio
else
# do something else for other types of terminal
fi
In general, you could rely on the environment given to the bash
process. For instance, the $TERM
variable, and run a similar if..then...else...fi
branch for [ "$TERM" = "xterm" ]
or something else. On case-to-case basis, you can investigate the differences in the environment via running env
in each console, save that to file as in env > output_console1.txt
, and diff output_console1.txt output_console2.txt
as suggested by dessert in the comments.