I was in the same boat as you and wrote a plugin that allows you to open a file by path from the prompt. Autocomplete and everything. It can be downloaded from:
bitbucket.org/chrisguilbeau/cg-sublime
Or if you just want to copy the text and paste it into a file:
[code]import sublime, sublime_plugin
from os import listdir
from os.path import commonprefix
from os.path import isdir
from os import getenv
class PromptOpenFilePath(sublime_plugin.WindowCommand):
def run(self):
currentDir = getenv('HOME') + '/'
activeView = self.window.active_view()
if activeView:
currentFilePath = activeView.file_name()
if currentFilePath:
currentFileParts = currentFilePath.split('/')
currentDir = '/'.join(
part for part in currentFileParts:-1]) + '/'
self._ip = self.window.show_input_panel(
"Open file:",
currentDir,
self.on_done,
self.on_change,
None
)
def on_change(self, text):
if not text:
return
if text.endswith('\t'):
currentFilePath = text.strip('\t')
currentFileParts = currentFilePath.split('/')
currentFile = currentFileParts-1]
currentDir = '/'.join(
part for part in currentFileParts:-1]) + '/'
filesInDir =
fileName
for fileName in listdir(currentDir)
if fileName.startswith(currentFile)
]
if filesInDir:
if len(filesInDir) > 1:
sublime.status_message(
', '.join(f for f in filesInDir))
newPath = currentDir + commonprefix(filesInDir)
else:
newPath = currentDir + filesInDir[0]
else:
newPath = text:-1]
sublime.status_message(
'No files match "%s"' % currentFile)
theEdit = self._ip.begin_edit()
allTextRegion = self._ip.full_line(0)
self._ip.replace(
theEdit,
allTextRegion,
newPath + (
isdir(newPath) and not newPath.endswith('/') and '/' or '')
)
self._ip.end_edit(theEdit)
def on_done(self, text):
try:
self.window.open_file(text)
numGroups = self.window.num_groups()
currentGroup = self.window.active_group()
if currentGroup < numGroups - 1:
newGroup = currentGroup + 1
else:
newGroup = 0
self.window.run_command("move_to_group", {"group": newGroup} )
except:
sublime.status_message('Unable to open "%s"' % text)
[/code]