取tig的sha提交数

时间:2018-09-27 18:07:49

标签: git sha tig

我喜欢使用tig客户端浏览git commits。

但是我现在错过了一件事。

是否有键绑定来获取我当前停留的git commit的sha数?

2 个答案:

答案 0 :(得分:3)

检查jonas/tig issue 557中建议的命令是否对您有用:

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

这会在剪贴板中复制current commit SHA1

Wiki binding page中,您还拥有Mac或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

OP megas建议in the comments使用git rev-parse

bind generic 9 !@sh -c "git rev-parse --short %(commit) | pbcopy"

答案 1 :(得分:1)

MacOS

bind generic 9 !@sh -c "printf '%s' %(commit) | pbcopy"

或者,复制短的 sha-1:

bind generic 9 !@sh -c "printf '%s' $(git rev-parse --short %(commit)) | pbcopy"

灵感来源:示例部分中的/tig/doc/tigrc(5) - Bind Command

VonC 的答案中列出的解决方案对我不起作用,因为粘贴的结果中有返回行 (⌘+V)。所以我无法在 tig :!git rebase -i [paste_here_hitting_⌘+V]~

中输入这样的命令