Below is a public gist that contains the code for this simple package. You can either drop the files directly into your User
package or create a folder for it in the Packages
folder (use Preferences > Browse Packages
to find either of those locations) as desired. If you go the User
package route, you may want to be sure you don’t accidentally clobber over any menu extension files you might have in there.
As I mentioned above, this is a pretty simple package overall, sort of ripe for future expansion in an alternate universe where I have an infinite amount of free time. Feel free to grab it and augment it or use it as the basis for something cooler (if you do that, drop me a line, that sounds neat ).
This provides two commands, one that opens a repository in Sublime Merge and one that opens the file history for the current file (and also opens the repository in Merge as a requirement).
The command to open the repo in Merge is available from the Command Palette and also in the context menu for folders in the side bar.
The command to open the history for the current file is available from the Command Palette and the context menu for files in the side bar . This opens the repo in merge and immediately enters the search mode focused on the appropriate file. If that file has a non-empty selection, it also adds a search term to see not only the history of that file but the history of the selected lines in that file.
Both commands disable themselves if they think they don’t apply (i.e. no git repo), which for the command palette makes them invisible. This is done by looking for a .git
directory (which is done in _find_git_root()
). This may or may not need to be modified to find things like worktrees and such (since until people talked about them when Merge was released I had no idea that they existed ).