如何修复在 MacOS 中从终端打开 sublime?
How to fix opening sublime from terminal in MacOS?
我希望能够从命令行在 MacOS (14.10.6) 中打开 sublime 文本编辑器。我找到了几个说明如何做到这一点 (HERE and HERE),但当然它对我不起作用。
我确实为 /usr/local/bin
中的应用程序创建了符号 link:
sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
位于 /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
的文件 是否存在。此外,文件夹 /usr/local/bin
在 PATH
.
的实际定义中 包含
但是在终端的命令行中输入命令却找不到
~$ sublime
-bash: sublime: command not found
证明:
$ls -al /usr/local/bin | grep sublime
lrwxr-xr-x 1 root admin 63 Jan 15 07:44 sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
$ echo $PATH
/usr/local/opt/python@3.8/bin:/usr/local/opt/python@3.8/bin:/Users/adietz/miniconda3/bin:/usr/local/bin:/Users/adietz/.pyenv/shims:/Users/adietz/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/puppetlabs/bin:/opt/X11/bin
有什么解决办法吗?
您可以使用open
命令,如手册所述:
DESCRIPTION
The open command opens a file (or a directory or URL), just as if you had
double-clicked the file's icon. If no application name is specified, the
default application as determined via LaunchServices is used to open the
specified files.
选项-a
适用于MacOS应用,则
open -a sublime\ text
(或类似的)应该有效。
然后您可以为它取别名并在需要时调用它:
alias sublime="open -a sublime\ text"
sublime
我希望能够从命令行在 MacOS (14.10.6) 中打开 sublime 文本编辑器。我找到了几个说明如何做到这一点 (HERE and HERE),但当然它对我不起作用。
我确实为 /usr/local/bin
中的应用程序创建了符号 link:
sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
位于 /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
的文件 是否存在。此外,文件夹 /usr/local/bin
在 PATH
.
但是在终端的命令行中输入命令却找不到
~$ sublime
-bash: sublime: command not found
证明:
$ls -al /usr/local/bin | grep sublime
lrwxr-xr-x 1 root admin 63 Jan 15 07:44 sublime -> /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl
$ echo $PATH
/usr/local/opt/python@3.8/bin:/usr/local/opt/python@3.8/bin:/Users/adietz/miniconda3/bin:/usr/local/bin:/Users/adietz/.pyenv/shims:/Users/adietz/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/puppetlabs/bin:/opt/X11/bin
有什么解决办法吗?
您可以使用open
命令,如手册所述:
DESCRIPTION
The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.
选项-a
适用于MacOS应用,则
open -a sublime\ text
(或类似的)应该有效。
然后您可以为它取别名并在需要时调用它:
alias sublime="open -a sublime\ text"
sublime