Compare commits
10 commits
7e5bbd1be5
...
a57111c2fd
Author | SHA1 | Date | |
---|---|---|---|
kale | a57111c2fd | ||
kale | 10445c0952 | ||
kale | 9264ed5aed | ||
kalmenn | 5768c236c5 | ||
kale | 26c869b714 | ||
kale | 8e88602784 | ||
kale | 971a126276 | ||
kalmenn | cac0da5998 | ||
kalmenn | 34655c2acf | ||
kalmenn | 53710c2622 |
26
config
26
config
|
@ -10,6 +10,7 @@
|
|||
|
||||
[core]
|
||||
editor = nvim
|
||||
quotepath = off
|
||||
|
||||
[init]
|
||||
defaultBranch = main
|
||||
|
@ -31,25 +32,28 @@
|
|||
s = "status"
|
||||
|
||||
# custom git log (inline)
|
||||
# sed part courtesy of: https://stackoverflow.com/questions/17371955/verifying-signed-git-commits/32038784#comment124980964_32038784
|
||||
lgi = "!f() { \
|
||||
git 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)' | \
|
||||
--format='%C(bold dim green)%h%C(auto) - %C(yellow)%cr %C(bold)→%C(reset) %s%C(reset bold yellow)%d <an>%an</an> <sig>%G?</sig> <sn>%GS</sn> %C(reset)' | \
|
||||
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>##'; \
|
||||
-e 's#<an>\\(.*\\)</an> <sig>N</sig> <sn>.*</sn>#\\x1b[0;2;3;37m- \\1#' \
|
||||
-e 's#<an>\\(.*\\)</an> <sig>E</sig> <sn>.*</sn>#\\x1b[1;33mMissing Key: \\x1b[0;2;3;37m\\1#' \
|
||||
\
|
||||
-e 's#<an>.*</an> <sig>\\([^N]\\)</sig>#<sig>\\1</sig>#' \
|
||||
\
|
||||
-e 's#<sig>G</sig>#\\x1b[0;1;32mGood:#' \
|
||||
-e 's#<sig>R</sig>#\\x1b[1;32mGood (revoked since):#' \
|
||||
-e 's#<sig>X</sig>#\\x1b[1;32mGood (expired since):#' \
|
||||
-e 's#<sig>U</sig>#\\x1b[1;33mUnknown Trust:#' \
|
||||
-e 's#<sig>Y</sig>#\\x1b[1;33mExpired Key:#' \
|
||||
-e 's#<sig>B</sig>#\\x1b[1;31mBAD:#' \
|
||||
-e 's#<sn>\\(.*\\)</sn>#\\x1b[0;2;3;37m\\1#'; \
|
||||
}; f"
|
||||
|
||||
# custom git log (always opens in pager)
|
||||
lg = "!f() { \
|
||||
git lgi $@ | \
|
||||
less -cr; \
|
||||
less --clear-screen --RAW-CONTROL-CHARS --chop-long-lines; \
|
||||
}; f"
|
||||
|
||||
# Inspired by, then evolved from:
|
||||
|
|
|
@ -4,6 +4,12 @@ no_home_identities=".local/share/git/identities"
|
|||
identities="$HOME/$no_home_identities";
|
||||
mkdir -p "$identities";
|
||||
|
||||
if [ ! -z "$(git config core.editor)" ]; then
|
||||
EDITOR="$(git config core.editor)";
|
||||
elif [ ! -z "$GIT_EDITOR" ]; then
|
||||
EDITOR="$GIT_EDITOR";
|
||||
fi
|
||||
|
||||
function yes_or_no { # courtesy of: https://stackoverflow.com/a/29436423
|
||||
while true; do
|
||||
read -p "$* [y/n]: " yn;
|
||||
|
@ -28,8 +34,11 @@ function display_parts() {
|
|||
local email="$3";
|
||||
local sigkey="$4";
|
||||
|
||||
printf "[$identity] $name <$email>";
|
||||
if [ ! -z $sigkey ]; then
|
||||
if [ ! -z "$identity" ]; then
|
||||
printf "[$identity] ";
|
||||
fi
|
||||
printf "$name <$email>";
|
||||
if [ ! -z "$sigkey" ]; then
|
||||
printf " (signing key: $sigkey)";
|
||||
fi
|
||||
printf "\n";
|
||||
|
@ -128,7 +137,7 @@ case $1 in
|
|||
echo;
|
||||
echo "Copies the config from an identity to the local git config.";
|
||||
echo "Using set instead of link essentially means that future changes made to the identity will not be synced with the local git config.";
|
||||
echo "If you wish for that be the case, you can manually include the identity in your local git config like so:";
|
||||
echo "If you wish for that be the case, consider using the include subcommand instead.";
|
||||
echo;
|
||||
echo "[include]";
|
||||
echo " path = ~/$no_home_identities/<identity>"
|
||||
|
@ -144,9 +153,47 @@ case $1 in
|
|||
[ ! -z "$email" ] && git config user.email "$email";
|
||||
[ ! -z "$sigkey" ] && git config user.signingKey "$sigkey";
|
||||
;;
|
||||
include)
|
||||
if [ -z "$2" ]; then
|
||||
echo "USAGE:";
|
||||
echo;
|
||||
echo " git identity include <identity>";
|
||||
echo;
|
||||
echo "Takes the path of the file in which the identity is defined and includes it in your local git config.";
|
||||
echo "This means that any changes made to the identity will be kept in sync in this local confif, risking a loss of consistency for the identity that's shown in your commits."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
get_identity "$2";
|
||||
|
||||
echo "Using this identity:";
|
||||
display_identity "$identity";
|
||||
echo;
|
||||
|
||||
git_config="$GIT_DIR/config";
|
||||
|
||||
echo "Writing to $git_config";
|
||||
echo;
|
||||
|
||||
echo -e "[include]\n path = ~/$no_home_identities/$identity" >> "$git_config";
|
||||
|
||||
res=0;
|
||||
|
||||
set -m;
|
||||
|
||||
#while [ "$res" -eq 0 ]; do # TODOOOOOOOOOOOO
|
||||
echo "Your new identity is:";
|
||||
display_parts "" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)";
|
||||
yes_or_no "Is this good (otherwise, review the config)";
|
||||
res=$?;
|
||||
if [ "$res" -eq 1 ]; then
|
||||
$EDITOR "$git_config";
|
||||
fi
|
||||
#done
|
||||
;;
|
||||
show)
|
||||
if [ -z "$2" ]; then
|
||||
display_parts "current" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)";
|
||||
display_parts "" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)";
|
||||
else
|
||||
get_identity "$2";
|
||||
display_identity "$identity";
|
||||
|
@ -163,7 +210,8 @@ case $1 in
|
|||
echo " import: Imports an identity from a gpg key";
|
||||
echo " remove: Removes a saved identity";
|
||||
echo " set: Sets the identity of the current git repo";
|
||||
echo " show: Show a saved identity or the identity of the current repo";
|
||||
echo " include: Includes the identity file in your local git config"
|
||||
echo " show: Show a saved identity or the identity that's currently effective";
|
||||
echo " list: List all saved identities";
|
||||
exit 1;
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue