将gitbash和conda集成到VSCode

在Windows时,总怀念Linux好用的bash,尤其是在VSCode中直接无缝调用bash的快感。如何在Windows中将gitbash和conda集成到VSCode?可以参考VSCode Python开发环境配置高级调试配置之前的内容。在VSCode中添加的个人设置应该是

1
2
3
"terminal.integrated.shell.windows": "C:/Program Files/Git/bin/bash.exe",
"terminal.integrated.shellArgs.windows": ["-l"],
"terminal.integrated.env.windows": {"python_env":"base"},

需要指出的是,脚本状态下的别名是没有开启的,详情参见在shell脚本中使用alias(shopt),所以在文件bash.bashrc中添加的应该是

1
2
3
4
5
6
7
8
9
10
# Fixup git-bash in non login env
shopt -q login_shell || . /etc/profile.d/git-prompt.sh
alias activate=". $(which activate)"
alias deactivate=". $(which deactivate)"

if [ $python_env ]; then
source activate $python_env
else
echo 'python_env NOT SET'
fi