diff --git a/.config/git/config b/.config/git/config index 27cf0a8..ddadd7b 100644 --- a/.config/git/config +++ b/.config/git/config @@ -40,20 +40,6 @@ autoSquash = true autoStash = true updateRefs = true -# me -[user] - name = Jan Andrle - email = andrle.jan@centrum.cz - signingkey = B3A25AED155AFFAB -[credential] - # see https://stackoverflow.com/questions/5343068/is-there-a-way-to-cache-https-credentials-for-pushing-commits/18362082#18362082 - helper = /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret -[credential "https://github.com"] - helper = !/usr/bin/gh auth git-credential -[credential "https://gist.github.com"] - helper = !/usr/bin/gh auth git-credential -[credential "https://git.dhl.com"] - helper = !/usr/bin/gh auth git-credential # my setup [core] editor = vim @@ -126,11 +112,5 @@ [am] # keepcr = true # to preserve line endings threeWay = true -[sendemail] - anotate = true - smtpserver = smtp.centrum.cz - # chainReplyTo = false - suppresscc = self - smtpuser = andrle.jan@centrum.cz - smtpencryption = ssl - smtpserverport = 465 +[include] + path = ./identities/current.conf diff --git a/.config/git/identities/default.conf b/.config/git/identities/default.conf new file mode 100644 index 0000000..200d188 --- /dev/null +++ b/.config/git/identities/default.conf @@ -0,0 +1,21 @@ +[user] + name = Jan Andrle + email = andrle.jan@centrum.cz + signingkey = B3A25AED155AFFAB +[credential] + # see https://stackoverflow.com/questions/5343068/is-there-a-way-to-cache-https-credentials-for-pushing-commits/18362082#18362082 + helper = /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret +[credential "https://github.com"] + helper = !/usr/bin/gh auth git-credential +[credential "https://gist.github.com"] + helper = !/usr/bin/gh auth git-credential +[credential "https://git.dhl.com"] + helper = !/usr/bin/gh auth git-credential +[sendemail] + anotate = true + smtpserver = smtp.centrum.cz + # chainReplyTo = false + suppresscc = self + smtpuser = andrle.jan@centrum.cz + smtpencryption = ssl + smtpserverport = 465 diff --git a/bin/git-identity b/bin/git-identity new file mode 100755 index 0000000..2c004a8 --- /dev/null +++ b/bin/git-identity @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail +config="$HOME/.config/git/identities" +input="${1:-}" +usage="Usage + git identity [|help|-] + git-identity --help +" +[ -z "$input" ] \ + && echo "$usage"\ + && echo -e "$config/current.conf … current identity:" \ + && cat "$config/current.conf" \ + && exit 0 +[ "$input" = --help ] \ + && input="help" +[ "$input" = help ] \ + && echo "$usage"\ + && echo '- _empty_: shows usage and current identity' \ + && echo '- : set identity' \ + && echo '- -: show path to identities directory' \ + && echo '- help: shows this help' \ + && echo -e '\n\nExamples' \ + && echo '- git identity' \ + && echo '- git identity user' \ + && echo '- ls $(git identity -)' \ + && echo -e '\n\nGit config' \ + && echo "- git config --global include.path '$config/current.conf'" \ + && exit 0 +[ "$input" = - ] \ + && echo "$config" \ + && exit 0 + +identity="$config/$input.conf" +[ ! -e "$identity" ] \ + && echo "No such identity: $input" >&2 \ + && echo "$identity" >&2 \ + && exit 1 + +ln --verbose --force "$identity" "$config/current.conf"