Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just created a symbolic link to sublime:

$ sudo ln -s /opt/SublimeText2/sublime_text /usr/bin/subl

The problem is that it opens the last project and the open I want:

$ subl my-project

or

$ ~/my-project/subl .

Both commands open Sublime Text 2 but twice, so I have two ST2 running.

How to solve this?

share|improve this question
    
Does this have anything to do with the symlink? This doesn't happen if you run /opt/SublimeText2/sublime_text my-project? –  Michael Mrozek Oct 9 '12 at 18:42
    
@MichaelMrozek with your example it works perfectly, withou nohup and the & –  Gerep Oct 10 '12 at 13:47
    
@MichaelMrozek nah!!! it still makes my terminal "busy" –  Gerep Oct 10 '12 at 19:18

2 Answers 2

up vote 4 down vote accepted

This is a bug in Sublime Text 2. Sublime remembers the last session and files that were opened after you exit the program by default. In some cases that is a good feature but for me and it seems as you as well it is not.

So what happens is when you create the symbolic link so you can type "subl" in the terminal window Sublime Text 2 will open the last session. If you type "subl ." it will open two windows the last session, and the current folder hierarchy in another window.

So what happened to me is I cd into a new Rails project folder and wanted to open just the current project folder in Sublime Text 2 and it was not happening.

So my work around was:

  1. Disable auto load sessions/last file(s): Open sublime text 2 and Go to, Preferences/Settings-User.

  2. Add these two lines: (if curly braces are present just add a comma to the end of last item in the list and the enter text into existing braces. If no items keep curly braces)

    {
      //disable auto-load sessions and files feature 
      "hot_exit": false,
      "remember_open_files": false
    }
    
  3. Open a terminal window and cd into whatever directory you want and enter "subl . &" this will keep the terminal window activate so you can still type commands that are associated with the project (ie running rspec test from inside sublime text 2 for current project) and open all the files in the current folder hierarchy. You can now open and save files but will not have to exit sublime text 2 to use terminal.

  4. Warning! If you exit the terminal window after opening sublime text 2 in this fashion, the sublime text window will close as well along with all the tabs you have open. If needs to close this terminal window instance for some reason and keep all your files open to keep working click into the terminal window instance and press Ctrl+Z'.

That's my work around for my current situation, maybe it my work for your situation or someone else's.

share|improve this answer
$ ./sublime_text --help 
Sublime Text 2 Build 2217

Usage: sublime_text [arguments] [files]         edit the given files
   or: sublime_text [arguments] [directories]   open the given directories

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
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

You may get the desired effect by giving the `-a' option which will send a tree of folders to a running instance of the application instead of opening a new window.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.