forked from ehamiter/Sublime-Text-2-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eric Hamiter
committed
May 25, 2011
1 parent
b86b2d3
commit a95d352
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Sublime Text 2 Plugins | ||
=============================================== | ||
|
||
This is just a handy place to store some plugins I use for ST2. | ||
|
||
|
||
blame.py | ||
======== | ||
|
||
blame.py is a Git blame plugin. It takes selected lines as arguments | ||
and outputs the data into the console. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
Copy **blame.py** into your ST2 User packages folder *(Sublime Text 2 > | ||
Preferences > Browse Packages... > User)* | ||
|
||
Usage | ||
----- | ||
|
||
Select text or click desired line(s), then context (right) click. | ||
Choose "Blame..." | ||
|
||
I've added this to my User Key Bindings, which works well (Command-Shift-B on a Mac): | ||
|
||
{ "keys": ["super+shift+b"], "command": "blame" } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
import sublime | ||
import sublime_plugin | ||
|
||
class BlameCommand(sublime_plugin.TextCommand): | ||
def run(self, edit): | ||
if len(self.view.file_name()) > 0: | ||
folder_name, file_name = os.path.split(self.view.file_name()) | ||
begin_line, begin_column = self.view.rowcol(self.view.sel()[0].begin()) | ||
end_line, end_column = self.view.rowcol(self.view.sel()[0].end()) | ||
begin_line = str(begin_line) | ||
end_line = str(end_line) | ||
lines = begin_line + ',' + end_line | ||
self.view.window().run_command('exec', {'cmd': ['git', 'blame', '-L', lines, file_name], 'working_dir': folder_name}) | ||
sublime.status_message("git blame -L " + lines + " " + file_name) | ||
|
||
def is_enabled(self): | ||
return self.view.file_name() and len(self.view.file_name()) > 0 |