在终端中使用。subl

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

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


当前回答

它工作!!!!MacOS Sierra 10.12.2

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

在终端subl找到它

其他回答

对于MAC 10.8+:

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

工作。

在运行Sublime Text 2的OS X Mavericks中,以下内容对我来说是有效的。

sudo ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/bin/subl

在查找器中找到文件并将其拖放到终端窗口中很方便,这样你就可以确保路径是正确的,我不是一个巨大的终端用户,所以这对我来说更舒服。然后您可以转到路径的开头并开始添加其他部分,例如简写UNIX命令。希望这能有所帮助

这是为了让它作为一个别名工作,而不是一个符号链接!

这将允许您在终端中运行额外的命令,而不会中断子会话。使用这里的许多符号链接答案(ln -s),导致终端进程在使用Sublime文本时持续。如果你想要分离,在Bash配置文件中创建一个别名,如下所示:

Test subl from your ST installation: First, navigate to a folder in Terminal that you want ST to open and enter the following command: /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl . NOTE: You may need to replace Sublime\ Text.app in the command above to Sublime\ Text\ 3.app or Sublime\ Text\ 2.app depending upon where the application is stored in your Applications directory. The . at the end of the above command opens the current working directory you are located in (again make sure you're in a directory that only contains a few files!). If you DO NOT get Sublime Text opening your current working directory then the next set of steps will NOT work. If nothing happens or you get an error from Terminal it will be because it couldn't find the Sublime Text application. This would mean that you would have to check what you've typed (spelling, etc.) OR that Sublime Text isn't installed! Check and update ".bash_profile": Now add the alias in your Bash Profile. Open it via vim ~/.bash_profile. These are the following lines that pertain to having subl work on the command line for Sublime Text: ## For Sublime Text 3 alias alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' ## For Sublime Text global editor preference **Optional export EDITOR='subl -w' I suggest always commenting your code in here with ##. The second line is OPTIONAL and just sets Sublime Text as the default editor. The flag -w has been added and you can find out more about flags by going to the Sublime Text docs: ST3 subl or ST2 subl If you do make any edits to this file once you have closed it, you need to source this file in your current session or close the terminal (tab) and open a new one. You can source this file by running the command source ~/.bash_profile Resolve any errors before moving to the final step.

我在Mac OSX Mavericks上使用oh-my-zsh,符号链接不适合我,所以我在.zshrc文件中添加了一个别名:

alias subl="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"

打开一个新终端,然后输入subl。

任何人寻找打开一个文件与升华的mac终端

open 'path/file.txt' -a '/Applications/Sublime Text.app'