【问题标题】:Mac Terminal link not workingMac终端链接不起作用
【发布时间】:2013-09-25 10:03:03
【问题描述】:

我正在尝试为 Sublime Text 3 创建命令行链接。

如果我运行/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl Sublime Text 会正常打开。

然后我运行sudo ln "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

重启终端,我得到了这个:

$ ls /usr/bin/subl
/usr/bin/subl
$ subl
-bash: subl: command not found

我也尝试在我的.profile alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" 中设置

但我也收到command not found

编辑:

/usr/bin/ 也在我的PATH

EDIT2:

我尝试重新启动我的计算机,但仍然无法正常工作。

似乎我创建的任何新别名都无法在我的.profile 中使用。

我试过ln -s "/usr/bin/mail" /usr/bin/testln,它确实奏效了。

EDIT3: 我通过在 .bash_profile 中添加别名来让它工作。我仍然想知道为什么我的ln 不起作用。

【问题讨论】:

  • 改为sudo ln -sf "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl,然后尝试。

标签: macos terminal sublimetext2 sublimetext sublimetext3


【解决方案1】:

你的符号链接命令

sudo ln "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl

不起作用,因为您都将路径括在引号中 用反斜杠转义了空格。引号使符号链接指向文字路径

/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

这是无效的。您应该使用

"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"

/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl

但不要将两者结合起来。

【讨论】:

  • 就是这样!非常感谢:)
【解决方案2】:

您可以在.profile 文件中将别名添加为:

alias subl="open -a Sublime\ Text"

在你这样做之后

subl .

应该没问题

【讨论】:

  • open -a Sublime\ Text 在我的终端中工作,但添加到 .profile 作为别名仍然给出-bash: subl: command not found
  • 似乎所有新别名都不起作用,不仅仅是 Sublime Text 的。我在.profile 中的现有别名确实有效。
  • 一旦有.bash_profile.profile 将被 bash 忽略。您可以使用内置的type bash 来检查subl 命令是什么:$ type subl
猜你喜欢
  • 2023-03-24
  • 1970-01-01
  • 2013-11-14
  • 2012-04-30
  • 2015-10-23
  • 1970-01-01
  • 2022-11-13
  • 1970-01-01
  • 2020-12-16
相关资源
最近更新 更多