Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2914

gitのメールアドレスを手軽に変えたい

$
0
0

やりたいこと。

gitのメールアドレスを手軽に変えたい。
毎回git config --local user.name aaaとかめんどい(そして、user.name=aaaって打って、できなくてイライラする)。
仕事用と私用で変えたいのです。

.bashrc

GIT_USERSの中を適宜変えて、$HOME/.bashrcに追加。

.bashrc
declare-AGIT_USERS=(["aaa"]="aaa@users.noreply.github.com"["bbb"]="bbb@exmaple.com")## git config complete
_set_git_config.sh(){if[${COMP_CWORD}== 1 ];then
    COMPREPLY=($(compgen-W'${!GIT_USERS[@]}'--${COMP_WORDS[${COMP_CWORD}]}))fi}function set_git_config(){if[-n"${1}"]&&[-n"${GIT_USERS[${1}]}"];then
        git config --local user.name ${1}
        git config --local user.email ${GIT_USERS[${1}]}fi
    git config --show-scope--list | grep user
}complete-F _set_git_config.sh set_git_config

使い方

set_git_config aaa
補完が利くのでset_git_config [TAB]とかで使えます。


Viewing all articles
Browse latest Browse all 2914

Trending Articles