Sublime Forum

Is it possible to copy a short sha from a commit

#1

I can right click a commit from the log and copy the full sha, is it possible to copy just the first 7 chars somehow?

0 Likes

#2

Go to the User directory by going to Preferences -> Browse Packages from the main menu and create a file by the name of Commit.sublime-menu. Paste the following and save the file.

[
	{
		"caption": "Copy short commit hash",
		"command": "copy_to_clipboard",
		"args": {
			"text": "$short_commit"
		},
	}
]

This should now add a new menu option Copy short commit hash in the menu that appears when you right click on any commit in the Commit side bar tab.

Unfortunately, this copies the first 8 characters of the SHA1 hash & I am not sure of how to get the first 7.

1 Like

#3

Just for a tiny improvement, it can use "caption": "Copy '$short_commit'", .

0 Likes

#4

I feel this might be a tad confusing with the existing Copy 'abcdef56...' menu item, which copies the full hash to the clipboard (even though it shows an ellipsis).

0 Likes

#5

Amazing, cheers folks

0 Likes