Thursday, October 6, 2022

[SOLVED] VSCode Integrated Terminal Doesn't Load .bashrc or .bash_profile

Issue

I have the following files to handle shell configuration:

#~/.bash_profile
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi

and

#~/.bashrc
... configure shell

If I open VSCode from the command line using code, my .bashrc is loaded whenever I add a new instance of the integrated shell.

However if I open VSCode via its icon, only my .profile is loaded.

How can I ensure my .bashrc is loaded instead?

I've tried various settings for the terminal.integrated.shellArgs.osx setting without any luck.


Solution

Simply add shell arguments to the VsCode settings.json file.

Paths to the settings.json file are as follows:

Windows: C:\Users\<username>\AppData\Roaming\Code\User\settings.json`

Linux:   $HOME/.config/Code/User/settings.json

Mac:     $HOME/Library/Application\ Support/Code/User/settings.json

Add one of the following:

"terminal.integrated.shellArgs.windows": ["-l"],

"terminal.integrated.shellArgs.linux": ["-l"],

"terminal.integrated.shellArgs.osx": ["-l"],

This will launch your shell of choice with the login argument. This will thus execute any user profile that is setup.



Answered By - Jose Ananio
Answer Checked By - Willingham (WPSolving Volunteer)