Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greggb/6066286 to your computer and use it in GitHub Desktop.
Save greggb/6066286 to your computer and use it in GitHub Desktop.
Perforce Plugin for Sublime Text. In ST3 this goes directly in the Packages directory.
[
{ "keys": ["f8"], "command": "p4_edit" }
]
import sublime, sublime_plugin, os, subprocess
class P4EditCommand(sublime_plugin.TextCommand):
def run(self, edit):
if self.view.file_name():
folder_name, file_name = os.path.split(self.view.file_name())
command = 'export P4CONFIG=.perforce; p4 edit '+file_name
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=folder_name, shell=True)
result, err = p.communicate()
self.view.set_status('p4',result+err)
sublime.set_timeout(self.clear,2000)
def clear(self):
self.view.erase_status('p4')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment