Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code VSCode终端windows-git bash别名被忽略_Visual Studio Code_Git Bash - Fatal编程技术网

Visual studio code VSCode终端windows-git bash别名被忽略

Visual studio code VSCode终端windows-git bash别名被忽略,visual-studio-code,git-bash,Visual Studio Code,Git Bash,我在c:\Users\user\.bash\u profile和c:\Program Files\Git\etc\profile.d\aliases.sh中创建了别名,但这两个配置都被配置为使用Git-bash的VSCode集成终端忽略: "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe", 如果我打开GitBash本身,别名就可以了 如何强制集成终端遵守配置?您可以尝试添加到设置中: //在

我在
c:\Users\user\.bash\u profile
c:\Program Files\Git\etc\profile.d\aliases.sh
中创建了别名,但这两个配置都被配置为使用Git-bash的VSCode集成终端忽略:

"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
如果我打开GitBash本身,别名就可以了


如何强制集成终端遵守配置?

您可以尝试添加到设置中:

//在Windows终端上使用的命令行参数。
“terminal.integrated.shellArgs.windows”:[
--登录“,-i”
],
-i
-强制shell以交互方式运行

--login
-使这个shell的行为就像它被login直接调用一样。当Bash作为交互式登录shell调用时,或者作为带有
--login
选项的非交互式shell调用时,它首先读取并执行文件/etc/profile中的命令(如果该文件存在)。读取该文件后,它将按顺序查找~/.bash_profile、~/.bash_login和~/.profile,并从第一个存在且可读的文件读取和执行命令

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


作为替代,您可以使用
.bashrc
文件而不是
.bash\u profile

使用“-login”和“-i”shell参数的解决方案对我不起作用。工作原理是在我的设置文件中使用bash“-rcfile”shell参数,如下所示:

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


。。。其中是我的Windows用户ID,别名命令位于名为“.bash\u profile”的文件中,该文件位于c:\Users\

我只需切换到我的根用户目录
c:\Users\user
,然后运行
source.bashrc
。这在我的机器上起了作用,希望能有所帮助

  • 在c:\Users\username中创建.bashrc
  • 添加别名,例如
    alias gotossh=“cd/c/users/username/.ssh”
  • 在终端中,在c:\Users\username中运行source.bashrc
  • 通过运行
    alias
  • 用户文件夹中可能没有需要注意的.bashrc文件。 另外,请记住在alias=“somecommand”中正确写入路径,并且在等号之间不要留任何空格


    从2020年起,无需添加shellArgs。

    这对我也适用。你知道如何在phpstorm上实现这一点吗?顺便问一下,这是干什么用的。