【问题标题】:.bash_profile aliases: command not found.bash_profile 别名:找不到命令
【发布时间】:2014-10-08 18:55:26
【问题描述】:

我无法让我的 .bash_profile 别名在我的 Mac OSX 终端上工作。我在 ~/ 目录中创建了一个 .bash_profile 文件,然后写了两行:

echo bash profile has loaded

alias prof=“open ~/.bash_profile”

我保存并在终端命令中输入:

. ~/.bash_profile

终端显示:

bash profile has loaded

-bash: alias: /Users/kennethlarose/.bash_profile”: not found

我一直在阅读别名配置文件,并且我相信我的语法是有效的。我知道配置文件正在采购,因为它显示回显,但无论我在别名中保存什么命令,终端都会显示相同的“未找到”消息。有人知道我还能尝试什么吗?

【问题讨论】:

  • 我也遇到了同样的错误,但这似乎是因为我想要别名的命令太长了。当我用更短的命令尝试相同的格式时,它工作得很好。因此,如果您想玩一个很长的命令(不是这种情况,但请注意其他读者),您应该将命令放入文件中并使文件可执行,如下所示 stackoverflow.com/questions/817060/…

标签: macos bash alias .bash-profile


【解决方案1】:

让我们问一下shellcheck!

In .bash_profile line 2:
alias prof=“open ~/.bash_profile”
           ^-- SC1015: This is a unicode double quote. Delete and retype it.

你的问题。 OS X 已经把你的双引号变成了 bash 无法识别的花哨的斜引号。如果您正在编程,您可能想要disable "smart quotes"

【讨论】:

  • 天啊!该链接帮助我解决了让我大吃一惊的自动拼写检查功能。为此 +1。
  • 天才回答,为什么还没有标记到超过 1000?干杯
  • 谢谢你!我绞尽脑汁想弄清楚为什么一个非常简单的别名不能正常工作。
猜你喜欢
  • 2022-01-10
  • 2020-08-25
  • 2016-01-13
  • 2012-04-11
  • 1970-01-01
相关资源
最近更新 更多