Sublime Forum

ST4: I can no longer open a directory from the command line

#1

In ST3 I was able to do this on Linux:

cd project/foo
subl .

This opens up the current directory in a new Sublime Text window.

On ST4 however this doesn’t do anything, besides focusing my last used Sublime Text window.

Apparently I can specify the path to a directory and it works, but I cannot specify the current . one?

0 Likes

#2

ST4 reuses a window if it contains that folder. Use the -n flag to force a new window.

0 Likes

#3

Honestly I don’t think that’s a good design. It’s just inconsistent. And what is the benefit behind it? I really don’t know. Preventing me from making the ‘mistake’ of opening a new window? Well, guess what, I want to create a new window by specifying a folder in the command line.

0 Likes

#4

I beleive it was changes specifically because it was indeed constantly creating new windows for people that already had existing ones open that they wanted to focus/resuse.

0 Likes

#5

No, that’s just a bug.

If I have a window that contains my projects folder open in it I cannot open it up using the current directory . shortcut, but if I specify ~/projects explicitly, oh wait, then I can.

Besides that, there is no harm in having more windows of the same thing open. They are all being auto updated anyway. I see how this can be related to your desktop environment setup, but it’s just not consistent.

  1. If I specify a file in the command line, Sublime opens it up inside the last active window
  2. If I specify a directory, Sublime opens it up in a new window

There is not third case.

0 Likes

#6

That’s surprising to me… Is ~/projects perhaps a symlink? Or is . a symlink?

Whether I run subl . or subl $(pwd -P), it focuses the already open window.

0 Likes

#7

Oh, wow, that’s so broken:

  1. ~/projects is a symlink, yes
  2. I have an index project always open, that contains ~/projects obviously
  3. I have another index project open, also symlinked, that contains just my projects

If I:

cd projects/some-project
subl .

It focuses up the main index project.

cd projects/some-project
subl ../some-other-project

It focuses the index project again.

cd projects/some-project
subl ../some-project-that-is-already-open

It focuses the index project again.

cd projects/some-project
subl ~/projects/some-project

It focuses the second index project, that is just for the ~projects.

If I close up the second index project, that’s just for the ~projects:

cd projects/some-project
subl ~/projects/some-project

It opens up the project in a new window as it should, disregarding the first index project that also contains it …

Like I said …
there should be just two cases …

0 Likes

#8

In the meantime I’m using this:

#!/bin/bash

subl=/path/to/sublime_text

if [[ -d $1 ]]; then
  $subl $1 -n
elif [[ -f $1 ]]; then
  $subl $1
fi

Still if the intention was to have a consistent behavior of focusing the window, then that’s not the case, at least not with symlinks or whatever else the reason might be.

0 Likes

#9

Yesterday I was surprised, too, when a folder was added to the existing folder but I still don’t get why this happened. I cannot reproduce it right now, unfortunately I don’t know from where I opened which folder (but I think it was inside an already opened project).

0 Likes

#10

Just to add to this, on top of the above observations, ST4 also adds the folder of the project into my index project window as well. I didn’t noticed that because my sidebar is usually hidden on the index project. So that means that even if I already have that project somewhere inside the folders of that window, it’s still being added at the bottom as new one. I don’t think that’s good.

EDIT: Oh wait, it did updated my sublime-project as well … that’s really bad, I’m handcrafting those.

0 Likes