VSCode终端窗口-git-bash别名被忽略 [英] VSCode terminal windows - git-bash aliases getting ignored

查看:183
本文介绍了VSCode终端窗口-git-bash别名被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 c:\ Users \ user \ .bash_profile C:\ Program Files \ Git \ etc \ profile.d \ aliases.sh ,但是这两个配置都被VSCode集成终端忽略,后者被配置为使用git bash:

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",

如果我自己打开GitBash-别名工作正常

if I open GitBash itself - aliases works fine

如何强制集成终端尊重配置?

how do I force integrated terminal to respect the configs?

推荐答案

您可以尝试添加设置:

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

-i -强制Shell交互运行.

-i - force the shell to run interactively.

-login -使此shell就像直接由login调用一样.当Bash作为交互式登录Shell或使用-login 选项作为非交互式Shell调用时,它首先从文件/etc/profile中读取并执行命令(如果该文件存在).读取该文件后,它将依次搜索〜/.bash_profile 〜/.bash_login 〜/.profile ,并从存在且可读的第一个命令中读取并执行命令.

--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.

当用名称为sh的交互式shell调用时,Bash查找变量ENV,如果定义了变量,则扩展其值,并将扩展后的值用作要读取和执行的文件的名称.由于以sh调用的shell不会尝试从任何其他启动文件读取和执行命令,因此 -rcfile 选项无效.以名称sh调用的非交互式外壳程序不会尝试读取任何其他启动文件.

作为替代方案,您可以使用 .bashrc 文件而不是 .bash_profile .

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

这篇关于VSCode终端窗口-git-bash别名被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆