在终端中使用。subl

它返回-bash: .subl:命令未找到

有人知道如何在macOS的命令行打开Sublime Text 3吗?


当前回答

根据Sublime的设置文档

echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile

工作很好。

其他回答

除非真的需要,否则不应该污染/usr/bin目录。 对于那些不受分发包管理器管理的二进制文件,我总是使用/usr/local/bin。为什么?因为如果包管理器更新了,它总是会替换/usr/bin中的文件。

我要做的是

sudo ln -s /Applications/Sublime\ Text。应用程序/内容/ SharedSupport / bin / subl /usr/local/bin/subl

如果你将subl设置为从命令行调用,打开当前目录的正确命令是:

苏布尔 .

“OS X命令行”是一个关于如何确保一切都已设置好的链接。

我用的是mac,这对我来说很管用:

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

总结一下实现目标的不同方法:

从终端打开崇高文本

open /Applications/Sublime\ Text.app/

使用sublime text打开当前路径下的特定文件(或提供需要打开的文件的路径)

open -a /Applications/Sublime\ Text.app/ myFileToOpen.txt

通过引入一个名为“sublime”的新别名并使用它,使您的命令变得简短 A. open bash_profile: 纳米~ / . bash_profile B.复制这一行以创建别名并保存并重启终端 alias sublime="open -a /Applications/ sublime \ Text.app" apple.txt将以sublime文本打开(必要时提供文件路径) 崇高apple.txt

在默认路径下创建文件对我来说不能作为菜单。Sublime-menu文件几乎覆盖了所有其他菜单选项,只留下一个自定义菜单。

对我来说有用的是在~/Library/Application Support/Sublime Text 3/Packages/User/Main路径下创建以下文件。sublime-menu(注意用户目录而不是默认目录):

[
    {
        "caption": "File",
        "mnemonic": "F",
        "id": "file",
        "children":
        [
            {
                "caption": "Open Recent More",
                "children":
                [
                    { "command": "open_recent_file", "args": {"index": 1 } },
                    { "command": "open_recent_file", "args": {"index": 2 } },
                    { "command": "open_recent_file", "args": {"index": 3 } },
                    { "command": "open_recent_file", "args": {"index": 4 } },
                    { "command": "open_recent_file", "args": {"index": 5 } },
                    { "command": "open_recent_file", "args": {"index": 6 } },
                    { "command": "open_recent_file", "args": {"index": 7 } },
                    { "command": "open_recent_file", "args": {"index": 8 } },
                    { "command": "open_recent_file", "args": {"index": 9 } },
                    { "command": "open_recent_file", "args": {"index": 10 } },
                    { "command": "open_recent_file", "args": {"index": 11 } },
                    { "command": "open_recent_file", "args": {"index": 12 } },
                    { "command": "open_recent_file", "args": {"index": 13 } },
                    { "command": "open_recent_file", "args": {"index": 14 } },
                    { "command": "open_recent_file", "args": {"index": 15 } },
                    { "command": "open_recent_file", "args": {"index": 16 } },
                    { "command": "open_recent_file", "args": {"index": 17 } },
                    { "command": "open_recent_file", "args": {"index": 18 } },
                    { "command": "open_recent_file", "args": {"index": 19 } },
                    { "command": "open_recent_file", "args": {"index": 20 } },
                    { "command": "open_recent_file", "args": {"index": 21 } },
                    { "command": "open_recent_file", "args": {"index": 22 } },
                    { "command": "open_recent_file", "args": {"index": 23 } },
                    { "command": "open_recent_file", "args": {"index": 24 } },
                    { "command": "open_recent_file", "args": {"index": 25 } },
                    { "command": "open_recent_file", "args": {"index": 26 } },
                    { "command": "open_recent_file", "args": {"index": 27 } },
                    { "command": "open_recent_file", "args": {"index": 28 } },
                    { "command": "open_recent_file", "args": {"index": 29 } },
                    { "command": "open_recent_file", "args": {"index": 30 } },
                    { "command": "open_recent_file", "args": {"index": 31 } },
                    { "command": "open_recent_file", "args": {"index": 32 } },
                    { "command": "open_recent_file", "args": {"index": 33 } },
                    { "command": "open_recent_file", "args": {"index": 34 } },
                    { "command": "open_recent_file", "args": {"index": 35 } },
                    { "command": "open_recent_file", "args": {"index": 36 } },
                    { "command": "open_recent_file", "args": {"index": 37 } },
                    { "command": "open_recent_file", "args": {"index": 38 } },
                    { "command": "open_recent_file", "args": {"index": 39 } },
                    { "command": "open_recent_file", "args": {"index": 40 } },
                    { "command": "open_recent_file", "args": {"index": 41 } },
                    { "command": "open_recent_file", "args": {"index": 42 } },
                    { "command": "open_recent_file", "args": {"index": 43 } },
                    { "command": "open_recent_file", "args": {"index": 44 } },
                    { "command": "open_recent_file", "args": {"index": 45 } },
                    { "command": "open_recent_file", "args": {"index": 46 } },
                    { "command": "open_recent_file", "args": {"index": 47 } },
                    { "command": "open_recent_file", "args": {"index": 48 } },
                    { "command": "open_recent_file", "args": {"index": 49 } },
                    { "command": "open_recent_file", "args": {"index": 50 } }
                ]
            }
        ]
    }
]

结果:

(出于安全考虑,需要模糊图像的某些部分)