Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take sha number of commit by tig

Tags:

git

sha

tig

I love to use tig client to navigate through git commits.

But I'm missing one thing for now.

Is there a key binding to take a sha number of a git commit I'm currently staying at?

like image 719
megas Avatar asked Dec 18 '22 20:12

megas


1 Answers

Check if the command proposed in jonas/tig issue 557 would work for you:

bind generic 9 !sh -c "echo -n %(commit) | xclip -selection c && echo Copied %(commit) to clipboard"

That would copy the current commit SHA1 in your clipboard.

In the Wiki binding page, you also have example for Mac or Cygwin:

bind generic 9 !@sh -c "git show -s --format=%s %(commit) | xclip -selection c" # Linux
bind generic 9 !@sh -c "git show -s --format=%s %(commit) | pbcopy" # Mac
bind generic 9 !@sh -c "git show -s --format=%s %(commit) > /dev/clipboard" # Cygwin

The OP megas proposes in the comments to use git rev-parse:

bind generic 9 !@sh -c "git rev-parse --short %(commit) | pbcopy"
like image 98
VonC Avatar answered Dec 28 '22 09:12

VonC