检查jonas/tig问题 557 中提出的命令是否适合您:
bind generic 9 !sh -c "echo -n %(commit) | xclip -selection c && echo Copied %(commit) to clipboard"
Run Code Online (Sandbox Code Playgroud)
这将复制剪贴板中的当前提交 SHA1。
在Wiki 绑定页面中,您还有 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
Run Code Online (Sandbox Code Playgroud)
该OP MEGAS提出的意见来使用git rev-parse:
bind generic 9 !@sh -c "git rev-parse --short %(commit) | pbcopy"
Run Code Online (Sandbox Code Playgroud)