为什么在超级终端中使用永久别名在 vs-code bash 终端中不起作用?
Why working permanent alias in hyper terminal doesn't work in vs-code bash terminal?
我在 Windows 10 机器上,我刚刚安装了 VS-Code 来代替 Atom 使用。我尝试在我创建的 VS-Code Bash 终端中使用永久别名并且在 Hyper Terminal 中运行良好,但它在 VS-Code 终端中不起作用。为什么会这样?我该如何解决?
我有
alias mongod="/c/Program\ files/MongoDB/Server/4.0/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/Server/4.0/bin/mongo.exe"
在我的“.bash_profile”文件中
在 VS-Code 终端中,尝试检查您的别名是否仍然定义:
alias mongod
cd ~
more .bash_profile
然后您将查看该别名是否仍然存在于 VSCode 环境中。
如果是:执行 source ~/.bash_profile
,别名应该可以使用。
另请参阅“Why ~/.bash_profile
is not getting sourced when opening a terminal?”
~/.bash_profile
is only sourced by bash when started in interactive login mode.
- When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source
~/.bashrc
.
因此,在您的情况下,将这些别名定义移动到 ~/.bashrc
。
我在 Windows 10 机器上,我刚刚安装了 VS-Code 来代替 Atom 使用。我尝试在我创建的 VS-Code Bash 终端中使用永久别名并且在 Hyper Terminal 中运行良好,但它在 VS-Code 终端中不起作用。为什么会这样?我该如何解决?
我有
alias mongod="/c/Program\ files/MongoDB/Server/4.0/bin/mongod.exe"
alias mongo="/c/Program\ Files/MongoDB/Server/4.0/bin/mongo.exe"
在我的“.bash_profile”文件中
在 VS-Code 终端中,尝试检查您的别名是否仍然定义:
alias mongod
cd ~
more .bash_profile
然后您将查看该别名是否仍然存在于 VSCode 环境中。
如果是:执行 source ~/.bash_profile
,别名应该可以使用。
另请参阅“Why ~/.bash_profile
is not getting sourced when opening a terminal?”
~/.bash_profile
is only sourced by bash when started in interactive login mode.- When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source
~/.bashrc
.
因此,在您的情况下,将这些别名定义移动到 ~/.bashrc
。