VSCode Integrated Terminal Doesn't Load .bashr

2019-06-28 02:42发布

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.

3条回答
Fickle 薄情
2楼-- · 2019-06-28 03:25

You could also try the following:

1 Create a file named /usr/local/bin/bash-login and add :

#!/bin/bash
bash -l

2 Run:

chmod +x /usr/local/bin/bash-login 

to make it executable.

3 On your VSC user settings add

   { "terminal.integrated.shell.osx": "/usr/local/bin/bash-login" }

The solution was described at https://github.com/Microsoft/vscode/issues/7263.

Hope it helps

查看更多
【Aperson】
3楼-- · 2019-06-28 03:41

I had the same problem with the Intellij Idea terminal on a Mac, the solution is the same for both. In settings change the path to the integrated terminal to "/bin/bash". Hope that helps.

enter image description here

查看更多
Emotional °昔
4楼-- · 2019-06-28 03:46

Simply add shell args to the settings. Tested on Windows with git bash but it should work same on Osx and Linux.

In C:\Users\<username>\AppData\Roaming\Code\User\settings.json or where your windows setting is: Add one of the following:

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

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

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

just below "terminal.integrated.shell.<platform>...

This will launch bash with the login argument.

查看更多
登录 后发表回答