14

I've created aliases in c:\Users\user\.bash_profile and in C:\Program Files\Git\etc\profile.d\aliases.sh but both configs getting ignored by VSCode integrated terminal, which is configured to use git bash:

"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

if I open GitBash itself - aliases works fine

how do I force integrated terminal to respect the configs?

4 Answers 4

27

You can try adding to the settings:

// The command line arguments to use when on the Windows terminal.
"terminal.integrated.shellArgs.windows": [
    "--login", "-i"
],

-i - force the shell to run interactively.

--login - make this shell act as if it had been directly invoked by login. When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

When invoked as an interactive shell with the name sh, Bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files.

Read more.


As an alternative you can use the .bashrc file instead of .bash_profile.

2
  • 1
    This works for me too. any idea on how to do this on phpstorm? By the way, what does this do?
    – GabMic
    Oct 17, 2018 at 18:15
  • GabMic, for PhpStorm. Bash options.
    – Victor S.
    Oct 18, 2018 at 8:10
1

The solution using the "--login" and "-i" shell arguments did not work for me. What did work was using the bash "-rcfile" shell argument, like this, in my settings file:

"terminal.integrated.shellArgs.windows": [ "-rcfile", "c:\Users\\.bash_profile", ],

... where <userid> is my Windows userid and the alias commands are in a file called ".bash_profile" that is located in c:\Users\<userid>

1

I simply switched to my root user directory c:\Users\user then ran source .bashrc. This did the trick on my machine, hope it helps.

1
  1. Create .bashrc in c:\Users\username
  2. Add an alias, e.g alias gotossh="cd /c/users/username/.ssh"
  3. In your terminal, run source .bashrc while in c:\Users\username
  4. Confirm that the alias works by running alias

You might not have a .bashrc file in the users folder which is important to note. Also remember to write the paths correct and don't leave any space between the equals in e.g alias="somecommand"

As of 2020 there is no need to add the shellArgs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.