Anto
Anto

Reputation: 7222

When opening a directory through command line, Sublime text opens two windows instead of one

If I open a directory in Sublime using the command line (subl path/to/my/folder/), Sublime will open two instances: one with the directory I asked for, and another one with the directory I opened last time I used Sublime. Any idea why ?

I don't know if it's revelant, but the problem occurs with Ubuntu 12.04.

Upvotes: 47

Views: 13512

Answers (5)

Antoine Bellion
Antoine Bellion

Reputation: 136

Update for Sublime Text V4 :

{
    // Mac only: This controls if an empty window is created at startup or not.
    "create_window_at_startup": true
}

Upvotes: 2

Simone Cianni
Simone Cianni

Reputation: 109

You can also use this to add new folder to the existing one:

subl . -a

Upvotes: 0

Nick F
Nick F

Reputation: 10122

I managed to fix this problem without having to disable Sublime's last session feature (which I like & don't wish to disable). Adding a -a flag to the subl command causes files to "open in current window", which prevents subsequent windows opening.

If this solution works for you, you can avoid the need to do it every time by creating an alias (in .bashrc or equivalent):

alias subl='subl -a'

...that way you can use the subl command without flags and it should behave as desired. If you ever do want to open a folder / file in a new window, you can just add the -n flag: eg. subl -n . (open this folder in a new window).

(Credit due to this answer on the Unix Stack Exchange)

Upvotes: 39

geynske006
geynske006

Reputation: 560

Thanks for the link, this worked for me.

Do the following: Preferences > Settings - User

Once you enter the file 'Preferences.sublime.settings' add between the brackets following lines.

{
  "hot_exit": false,
  "remember_open_files": false
}

Upvotes: 44

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83418

You are most likely using Sublime's save last session feature.

You can disable it:

http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Disable_automatic_loading_of_the_last_session

Upvotes: 33

Related Questions