Created
July 5, 2011 20:12
-
-
Save coldnebo/1065808 to your computer and use it in GitHub Desktop.
simple script to checkout files with perforce while in sublime text 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "keys": ["f8"], "command": "p4_edit" } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
Also, for Mac, I changed the key to F13 to avoid conflicts on the mac keyboard and specified the p4 location (/usr/local/bin/p4
). This probably varies according to your setup, so I'll leave it to you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use with Sublime Text 2, copy both these files into
~/.config/sublime-text-2/Packages/User
On Mac OSX, the path is:
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User