Sublime Forum

Determine directory of non-file view

#1

Is there a way to find out the directory of a non-file view? Or, better still, manipulate the directory?

I would like to create a view that is not tied to a file, and when the user hits Command+O in that view (I’m on a Mac), the file chooser comes up and I want to determine which directory that file chooser will be displaying.

0 Likes

#2

use os.getcwdu() perhaps?

0 Likes

#3

Thank you, but I’m afraid that doesn’t work. I opened a file, then opened the console and executed

import os
os.getcwdu()

… and the result was “/”. But Command+O showed me a different directory.

I also tried it with a dired view, and it didn’t work there, either.

0 Likes

#4

A buffer without an associated file doesn’t have a directory. The virtual current directory is changed only when a buffer associated with a file is selected. There’s currently no API that exposes the virtual current directory.

0 Likes

#5

Thanks for the clarification, Jon.

0 Likes