【问题标题】:Why working permanent alias in hyper terminal doesn't work in vs-code bash terminal?为什么在超级终端中工作的永久别名在 vs-code bash 终端中不起作用?
【发布时间】:2019-10-05 07:55:00
【问题描述】:

我在 Windows 10 机器上,我刚刚安装了 VS-Code 来代替 Atom。我尝试在我创建的 VS-Code Bash 终端中使用永久别名,并且在超级终端中运行良好,但它在 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”文件中

【问题讨论】:

标签: visual-studio-code git-bash


【解决方案1】:

在 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 仅在以交互式登录模式启动时由 bash 提供。
  • 当您打开终端时,终端会以(非登录)交互模式启动 bash,这意味着它将获取 ~/.bashrc

因此,在您的情况下,将这些别名定义移动到 ~/.bashrc

【讨论】:

  • 在文件中。
  • @tseevag 好的,那么当你输入mongod(别名)时你会看到什么?
  • alias mongod 是否返回别名的定义?如果没有,您可以在输入source ~/.bash_profile后重试吗?
  • @tsevag 太好了!我已经相应地编辑了答案。
  • @tsevag 我已经在答案中添加了这些别名默认不活动的原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-13
  • 2017-06-25
  • 1970-01-01
  • 2022-10-25
相关资源
最近更新 更多