使用命令行在Sublime Text 3中打开文件夹 [英] Open a folder in Sublime Text 3 using command line

查看:1937
本文介绍了使用命令行在Sublime Text 3中打开文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在sublime Text 3中打开一个目录。

I'm trying to open a directory in sublime Text 3.

我可以使用 subl 命令。

I can launch sublime from the command line using the subl command.

帮助文本显示以下内容:

The help text show the following:

Sublime Text build 3059

Usage: subl [arguments] [files]         edit the given files
   or: subl [arguments] [directories]   open the given directories
   or: subl [arguments] -               edit stdin

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -s or --stay:        Keep the application activated after closing the file
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).

Filenames may be given a :line or :line:column suffix to open at a specific
location.

因此,要打开一个目录,我应该能够使用以下

Thus to open a directory I should be able to use the following

subl ./folder_name

但不适用于我。 Sublime打开(有空的新文档),我在侧边栏中看不到该文件夹​​。

but that does not work for me. Sublime does open (with a empty new document) and I cannot see the folder in the side bar.

我做错了...

BTW。我使用的鱼壳与'哦我的鱼'加载项(我还添加了升级附加)...

BTW. I'm using the fish shell with the 'Oh my fish' Add-on (I have also added the sublime add- on)...

推荐答案

仅限Mac或Linux

最安全的方法是从Sublime可执行文件(subl)创建一个符号链接到$ PATH中已有的文件夹(例如 / usr / local / bin / ) 。如果你做上面的;你必须每次更新sublime更新...

The best & safest way to do this is to create a symbolic link from the Sublime executable file (subl) to a folder already in your $PATH (e.g. /usr/local/bin/). If you do the above; you'll have to update this every time sublime updates...

对于运行BASH的用户(即大多数人):

For users running BASH (i.e. most people):

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

如果这不起作用,请在主目录中创建一个bin文件夹(如果还不存在),将它添加到PATH变量并创建指向该文件的软链接)。

If that doesn't work, create a bin folder in your home directory (if one does not already exist), add it to your PATH variable and create a soft link to that file).

mkdir $HOME/bin
export PATH=$HOME/bin:$PATH
ln -s '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' $HOME/bin/subl


我安装了不同版本的命令行subl和sublime text三。

I had different versions of the command line subl and sublime text three installed.

命令,然后重新添加,这解决了我的问题...

I simply removed the subl command and then re-added and that fixed the problem for me...

对于那些可能会发现这有用 - 这是我做了:

For those who may find this useful - this is what I did:

subl -v

这显示了我的命令行的建立sublime,当我检查这与我的实际Sublime的版本。我注意到命令行 subl 是一个旧版本。

This showed me the build of the command line sublime, when I checked this against the version of my actual Sublime. I noticed that the command line subl was an older build.

所以我试图找到命令的位置line subl:

So I tried to find the location of the command line subl:

which subl

这给你一个位置(对我来说这是 / usr / bin / subl

This gives you a location (for me this was /usr/bin/subl)

所以我试图删除这个命令行sublime:

So I tried to remove this command line sublime:

sudo rm /usr/bin/subl   (use `sudo` only if necessary)

接下来将Subl命令行程序重新复制到它的位置。对于Mac上的Sublime Text 3,这是:

Next re-copy your Subl command line program back to it's location. For Sublime Text 3 on a mac, this was:

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

sudo )。

(as before only use sudo if necessary).

然后在正确使用它之前,我会花一两秒钟看看帮助文本说明其用法:

Then before you start using it properly, I would take a second or two to look at the help text, which explains it's usage:

subl -h

在这之后,一切工作都很完美:)

After this, everything was working perfectly :)

这篇关于使用命令行在Sublime Text 3中打开文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆