-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathquickOpenProject.py
More file actions
36 lines (29 loc) · 1.2 KB
/
Copy pathquickOpenProject.py
File metadata and controls
36 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sublime_plugin
import os
##
# Open project from a quickPanel
#
# Specify the directory holding all your project files as an argument to the command.
# Bind it via (examples):
# { "keys": ["ctrl+shift+alt+p"], "command": "quick_open_project", "args": {"dir": "/foo/bar/sublime-projects"} },
#
# @author Jordi Boggiano <j.boggiano@seld.be>
##
class QuickOpenProjectCommand(sublime_plugin.WindowCommand):
projects = []
def want_file(self, f):
root, ext = os.path.splitext(f)
return os.path.isfile(f) and ext == '.sublime-project'
def open_project(self, index):
if index == -1:
return
# TODO fix this call, ST2/3 do not support it
self.window.run_command('open_project', [self.projects[index]])
def run(self, dir):
projectsPath = str(dir)
displayFiles = [f for f in os.listdir(projectsPath) if self.want_file(projectsPath + '/' + f)]
displayFiles.sort()
self.projects = [projectsPath + '/' + str(f) for f in displayFiles]
for i in range(len(displayFiles)):
displayFiles[i] = displayFiles[i].replace('.sublime-project', '')
self.window.show_quick_panel(displayFiles, self.open_project)