Skip to content

Commit

Permalink
Added folder to project functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
al63 committed May 13, 2012
1 parent 25de54a commit 182ea05
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
16 changes: 13 additions & 3 deletions README.md
Expand Up @@ -23,17 +23,27 @@ regardless of system. However, this is untested on Windows.

__Installation__

Sublime Files can be installed through Sublime Package Control
Sublime Files can be installed through Sublime Package Control.

----------

__Usage__

Sublime files an be activated with the command palette command: "Sublime Files: Open Navigator", or with
the key command ctrl+super+n (or ctrl+alt+n for windows).

Selecting a directory will nagivate to the directory and selecting a file will open the file.
Selecting "." (current directory) will pop up a small list of actions that can be applied onto the directory.


There are a few notable options:


- Selecting "." (current directory) will pop up a small list of actions that can be applied onto the directory. Mainly,
a user can create new files, add the directory to the current project, and open a terminal at the directory.

- Selecting "~/" navigates to the home directory.

- Selecting "\* To current View" navigates to the directory of the current file being editted


----------

Expand Down
25 changes: 20 additions & 5 deletions sublime_files.py
@@ -1,6 +1,6 @@
import sublime, sublime_plugin
import os, sys, inspect
from subprocess import call
import os, sys, glob
import subprocess

class SublimeFilesCommand(sublime_plugin.WindowCommand):
def run(self, command):
Expand Down Expand Up @@ -71,10 +71,10 @@ def handle_navigator_option(self, call_value):
#Options for when a user selects '.'
def open_directory_options(self):
if self.home == 'HOME':
self.directory_options = ['* Create new file', '* Set bookmark here','* Back']
self.directory_options = ['* Add folder to project', '* Create new file', '* Set bookmark here','* Back']
#Terminal opening. only for posix at the moment
if os.name == 'posix' and self.term_command is not None:
self.directory_options.append('* Open terminal here')
self.directory_options.insert(0,'* Open terminal here')
self.window.show_quick_panel(self.directory_options, self.handle_directory_option, sublime.MONOSPACE_FONT)


Expand All @@ -95,10 +95,12 @@ def handle_directory_option(self, call_value):
for element in directory_split:
actual_dir += element + '\ '
os.system(self.term_command + actual_dir[:len(actual_dir)-2])
elif selection == '* Add folder to project':
sublime_command_line(['-a', os.getcwd()])


def handle_new_file_name(self, file_name):
call(['touch', file_name])
subprocess.call(['touch', file_name])
self.window.open_file(file_name)


Expand All @@ -109,3 +111,16 @@ def sort_files(filename):
if filename[-1] == '/':
total_weight += 1
return total_weight

#Hack to add folders to sidebar (thank you wbond for your forum post!)
def get_sublime_path():
if sublime.platform() == 'osx':
return '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl'
elif sublime.platform() == 'linux':
return open('/proc/self/cmdline').read().split(chr(0))[0]
else:
return sys.executable

def sublime_command_line(args):
args.insert(0, get_sublime_path())
return subprocess.Popen(args)
Binary file modified sublime_files.pyc
Binary file not shown.

0 comments on commit 182ea05

Please sign in to comment.