22
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tigでコミットIDをクリップボードへコピーする

Posted at

以下のような方法だとうまくいかなかった。

.gitconfig
[tig "bind"]
  main = C1 !@echo '%(commit)' | pbcopy
  main = C2 !@bash -c "echo -n '%(commit)' | pbcopy"

※ pbcopyはMacのコマンドなので適当に読みかえて下さい

以下のissueに一応の解決策が載っていました。
(なんか色々パッチを書いてる人がいるけど、取り込まれてはいない模様)

##解決案

以下のようにaliasを経由させるとうまくいきます。

.gitconfig
[alias]
  pbcopy = !printf "$1" | pbcopy

  ## 代案
  # pbcopy = !bash -c 'echo -n "$1" | pbcopy' --  # 上記issueに載ってた方法
  # pbcopy = !echo "$1" | pbcopy  # 末尾に改行が入っても良ければこれでも良い

[tig "bind"]
  main = C !@git pbcopy %(commit)

上記設定では、全て .gitconfig に書きましたが、tigの設定は .tigrc に書くこともできます。
お好みでどうぞ。

.tigrc
bind main C !@git pbcopy %(commit)
22
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?