ホームディレクトリ配下の.gitconfig
に以下の設定を書いておくと、git jump
とかgit bcp
と打ち込むだけで、移動したり、ブランチ名をコピーできます。
ただし、pecoコマンドが入っているのでインストールはお忘れなきよう。
~/.gitconfig
[alias]
jump = !git checkout $(git branch | sed 's/*//g' | sed 's/ //g' | peco)
bcp = !git branch | peco | sed 's/*//g' | sed 's/ //g' | tr -d '\n' | pbcopy
なお、!について、ですが、StackOverFlowによると、
If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command.
!がついてると、shell commandとして見做すということだそうです。
(ついてないと→な感じのエラーが出ます。expansion of alias 'bcp' failed; 'git' is not a git command
)。