initial commit

This commit is contained in:
kalmenn 2023-12-21 22:49:17 +01:00
commit 243ce1b91d
Signed by: kalmenn
GPG key ID: F500055C44BC3834
2 changed files with 77 additions and 0 deletions

34
config Normal file
View file

@ -0,0 +1,34 @@
[core]
editor = nvim
[init]
defaultBranch = main
[commit]
gpgsign = true
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[user]
useConfigOnly = true
[alias]
lg-inline = "log --graph --branches --all --date=human --color --format='%C(bold dim green)%h%C(auto) - %C(yellow)%<(12)%cr %C(bold)→%C(reset) %s%C(dim white) - %an %C(bold green)<sig>%G?</sig>%GS%C(reset cyan)%d%C(reset)'"
# sed part courtesy of: https://stackoverflow.com/a/32038784
lg = "!f() { \
git lg-inline $@ |\
sed \
-e 's#<sig>G</sig>#Good Signature: #' \
-e 's#<sig>B</sig>#\\x1b[31mBAD#' \
-e 's#<sig>U</sig>#\\x1b[33mUnknown Trust: #' \
-e 's#<sig>X</sig>#Good | Expired#' \
-e 's#<sig>Y</sig>#\\x1b[33mExpired Key#' \
-e 's#<sig>R</sig>#\\x1b[31mRevoked#' \
-e 's#<sig>E</sig>#\\x1b[33mMissing Key#' \
-e 's#<sig>N</sig>##' | \
less -cr; \
}; f"
ck = "checkout"
s = "status"
# https://www.micah.soy/posts/setting-up-git-identities/
identity = "!~/.config/git/scripts/identity.sh"

43
scripts/identity.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/sh
if [ -z "$1" ]; then
echo "USAGE:";
echo " git identity <gpg key id>";
echo;
echo "current identity:";
echo " name = $(git config user.name)";
echo " email = $(git config user.email)";
echo " key = $(git config user.signingKey)";
exit 1;
fi
uid_regex="([^\(]*)\s*(\((.*)\))?\s*<(.*)>";
uid=$(gpg --with-colons -K $1 | awk -F: '$1=="uid" {print $10; exit}');
if [ -z "$uid" ]; then
echo "ERROR: found no gpg key matching this";
exit 1;
fi
name=$(printf "$uid" | sed --regexp-extended -e "s/$uid_regex/\1/");
email=$(printf "$uid" | sed --regexp-extended -e "s/$uid_regex/\4/");
echo "using this identity:";
echo " name = $name";
echo " email = $email";
git config --local user.name "$name"
git config --local user.email "$email"
keyid=$(gpg -K --with-colon $1 | awk -F: '$12~/.*s.*/ {print $5; exit}');
# TODO: if multiple found, bring up a dialog to select the right key
if [ -z "$keyid" ]; then
echo "WARNING: found no subkey with signing capabilities. No signing key will be set";
git config --local --unset user.signingKey;
else
echo " key = $keyid";
git config --local user.signingKey "$keyid";
fi