Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Integrated Terminal Doesn't Load .bashrc or .bash_profile

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.

like image 531
Undistraction Avatar asked Aug 13 '18 11:08

Undistraction


People also ask

Why is terminal not working in VS Code?

Changing Default Command Line Shell Here, choose Select Default Profile. Then, select any other type of command line shell. Then, restart vs code and try working on terminal.

How do I open a .bashrc file in VS Code?

bashrc listed if you scroll down, but you can simply type in . bashrc , so it says /home/you/. bashrc . Then press Enter or click OK .

Where does VS Code run its shell scripts?

When VS Code launches for the first time, to source your "development environment," it launches your configured shell as a login shell, which runs your ~/.profile / ~/.bash_profile / ~/.zprofile scripts.

What is the difference between bash_profile and bashrc?

To everybody suggesting using .bashrc as a replacement for .bash_profile, it's important to distinguish between the two, as they are different: .bash_profile is executed at login. .bashrc is executed each time a bash instance is created, including sub-shells. Using .bashrc for such settings might cause errors and even be dangerous.

Is there a command to skip the shell in VS Code?

There is a hardcoded list of commands, which skip being processed by the shell and instead get sent to the VS Code keybinding system. Customize this list with the terminal.integrated.commandsToSkipShell setting.

Why can't I launch my preferred shell in the integrated terminal?

Note: If you're having trouble launching your preferred shell in the integrated terminal, it may be due to your shell's configuration or a VS Code terminal setting. There's a dedicated troubleshooting guide to help you with these sorts of problems. The terminal tabs UI is on the right side of the terminal view.


1 Answers

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.

like image 126
Jose Ananio Avatar answered Sep 28 '22 15:09

Jose Ananio