Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions sublime_files.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ def run(self, command):
try:
self.home
except:
self.current_dir = ""
# first time starting up. ugly, but works
settings = sublime.load_settings('SublimeFiles.sublime-settings')
if os.name == 'nt':
self.home = 'USERPROFILE'
else:
self.home = 'HOME'
try:
os.chdir(os.path.dirname(sublime.active_window().active_view().file_name()))
self.current_dir = os.path.dirname(sublime.active_window().active_view().file_name())
os.chdir(self.current_dir)
except:
os.chdir(os.getenv(self.home))
self.bookmark = None
Expand All @@ -31,6 +33,8 @@ def run(self, command):

# function for showing panel for changing directories / opening files
def open_navigator(self):
self.current_dir = os.getcwd()
print(self.current_dir)
self.dir_files = ['[' + os.getcwd() + ']',
bullet + ' Directory actions', '..' + os.sep, '~' + os.sep]

Expand All @@ -45,10 +49,11 @@ def open_navigator(self):

for element in os.listdir(os.getcwd()):
ignore_element = False
for ignore_pattern in self.ignore_list:
if fnmatch(element, ignore_pattern):
ignore_element = True
break
if self.ignore_list:
for ignore_pattern in self.ignore_list:
if fnmatch(element, ignore_pattern):
ignore_element = True
break
if not ignore_element:
fullpath = os.path.join(os.getcwd(), element)
if os.path.isdir(fullpath):
Expand All @@ -61,10 +66,11 @@ def open_navigator(self):
self.dir_files.insert(2, bullet + ' To bookmark (' + self.bookmark + ')')
if self.window.active_view() and self.window.active_view().file_name():
self.dir_files.insert(2, bullet + ' To current view')
self.window.show_quick_panel(self.dir_files, self.handle_navigator_option, sublime.MONOSPACE_FONT)
sublime.set_timeout(lambda: self.window.show_quick_panel(self.dir_files, self.handle_navigator_option, sublime.MONOSPACE_FONT), 10)

# handles user's selection from open_navigator
def handle_navigator_option(self, call_value):
os.chdir(self.current_dir)
if call_value != -1:
option = self.dir_files[call_value]
if call_value == 0:
Expand Down Expand Up @@ -97,7 +103,7 @@ def open_directory_options(self):
# terminal opening. only for osx/linux right now
if os.name == 'posix' and self.term_command:
self.directory_options.insert(0, bullet + ' Open terminal here')
self.window.show_quick_panel(self.directory_options, self.handle_directory_option, sublime.MONOSPACE_FONT)
sublime.set_timeout(lambda: self.window.show_quick_panel(self.directory_options, self.handle_directory_option, sublime.MONOSPACE_FONT), 10)

# handle choice for when user selects option from current directory
def handle_directory_option(self, call_value):
Expand Down