Home Download Buy Blog Forum Support

How to get currently open project path

How to get currently open project path

Postby burn on Fri Jul 09, 2010 2:10 am

Hey guys,

I couldn't find anything regarding this in the APIs. Can someone tell me if it's possible to:

a) Determine if a project is currently open
b) If so, retrieve its root's path

Cheers,

Burn
burn
 
Posts: 9
Joined: Wed Jan 27, 2010 1:23 pm

Re: How to get currently open project path

Postby guillermooo on Fri Jul 09, 2010 8:22 am

The API is rather limited in regards to project support.

To determine whether a project has been loaded, you may trap the onProjectLoad event. I don't think you can tell what project file has been loaded, though.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: How to get currently open project path

Postby burn on Fri Jul 09, 2010 2:10 pm

Too bad :( I really wanted to get all Tortoise (svn/git) options in a quickSelect panel, I guess I'll have it only work per file for now, and stick to global shortcuts for the rest, there I can get the $ProjectDir. Hope we'll get more access to information in the APIs later on.
burn
 
Posts: 9
Joined: Wed Jan 27, 2010 1:23 pm

Re: How to get currently open project path

Postby willi297 on Sat Jul 10, 2010 9:14 pm

I recently created a TortoiseSVN plugin that is on the community wiki. I only use key bindings/menus for now, but I think converting it to use a quickpanel would be nice. I really just use $ProjectDir right in my bindings. Actually, the plugin is ONLY bindings, so thats why I don't have the issue you are experiencing. It would be nice to have access to all the same sublime vars from within plugin code thought too.
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: How to get currently open project path

Postby gpfsmurf on Sun Jul 11, 2010 7:48 am

burn wrote:a) Determine if a project is currently open
b) If so, retrieve its root's path

"window.project()" will tell you if a project is open
"window.project().fileName()" will tell you its path

I don't think it's documented, so it's possible it changes in the future.
Anyways, you can get more hidden info like that by introspecting variables. Try "dir(window)" and "dir(window.project())"
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: How to get currently open project path

Postby guillermooo on Sun Jul 11, 2010 8:47 am

Cool! I was too lazy to check. Also, looking into Packages/Default may help to learn other undocumented API calls.
guillermooo
 
Posts: 728
Joined: Thu Jul 23, 2009 9:06 am

Re: How to get currently open project path

Postby chuim on Thu Sep 22, 2011 10:23 pm

Just re-asking here for this thread was more discussed than the previous one: does anyone know the project() was changed for Sublime 2? I'm pretty sure it doesn't exist in the window instances anymore...
chuim
 
Posts: 6
Joined: Thu Sep 22, 2011 10:16 pm

Re: How to get currently open project path

Postby jbjornson on Fri Sep 23, 2011 8:28 am

From what I can tell, the only project information available in the api is window.folders(), which gives you a list of the project folders.
jbjornson
 
Posts: 348
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: How to get currently open project path

Postby whoshallsucceed on Thu Nov 24, 2011 2:20 pm

Right. But if you're working on a project which its containing folder is not in your sublime-project file, then you still can't know the path of your project.
whoshallsucceed
 
Posts: 5
Joined: Tue Jan 25, 2011 12:27 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests