问题
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?
回答1:
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"
来源:https://stackoverflow.com/questions/52542803/take-sha-number-of-commit-by-tig