Open a folder in Sublime Text 3 using command line

2019-01-31 00:43发布

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

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

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.

Am I doing it wrong...

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

9条回答
孤傲高冷的网名
2楼-- · 2019-01-31 01:07

I was having trouble opening sublime text 3 with sublime text 2 currently installed. To fix this issue:

1) open /usr/local/bin from terminal.

2) locate and delete subl within bin folder

3) copy and pasted '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' /usr/local/bin/subl into terminal.

4) locate new subl within bin folder

5) used subl in terminal to verify command opens sublime text 3 properly.

6) used subl -v and got Sublime Text Build 3083

查看更多
迷人小祖宗
3楼-- · 2019-01-31 01:08

That's because by default the side bar does not show, you can show the side bar by

View > Side Bar> Show Side Bar

[enter image description here1

查看更多
Luminary・发光体
4楼-- · 2019-01-31 01:08

There is probably an alias with the name subl provided by 'Oh my fish' . You can check if there is an alias by using alias command in the terminal. This will display all aliases for your session. If you have it on the list then it is colliding with your symbolic link. Disable the alias by fixing the source or by using unalias subl (unalias will only fix it for the current session)

I had this problem when using bash-it aliases for osx. Disabling it fixed the problem for me.

查看更多
登录 后发表回答