Take sha number of commit by tig

廉价感情. 提交于 2021-02-07 19:48:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!