Compare commits
	
		
			No commits in common. "a57111c2fdad19725fd0025025fe3e31df754d9c" and "7e5bbd1be5472f0686d622467316776cbcfaf027" have entirely different histories.
		
	
	
		
			a57111c2fd
			...
			7e5bbd1be5
		
	
		
					 2 changed files with 16 additions and 68 deletions
				
			
		
							
								
								
									
										26
									
								
								config
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								config
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -10,7 +10,6 @@
 | 
			
		|||
 | 
			
		||||
[core]
 | 
			
		||||
    editor = nvim
 | 
			
		||||
    quotepath = off
 | 
			
		||||
 | 
			
		||||
[init]
 | 
			
		||||
    defaultBranch = main
 | 
			
		||||
| 
						 | 
				
			
			@ -32,28 +31,25 @@
 | 
			
		|||
    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)%cr %C(bold)→%C(reset) %s%C(reset bold yellow)%d <an>%an</an> <sig>%G?</sig> <sn>%GS</sn> %C(reset)' | \
 | 
			
		||||
            --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 \
 | 
			
		||||
            -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#'; \
 | 
			
		||||
            -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>##'; \
 | 
			
		||||
    }; f"
 | 
			
		||||
 | 
			
		||||
    # custom git log (always opens in pager)
 | 
			
		||||
    lg = "!f() { \
 | 
			
		||||
        git lgi $@ | \
 | 
			
		||||
        less --clear-screen --RAW-CONTROL-CHARS --chop-long-lines; \
 | 
			
		||||
        less -cr; \
 | 
			
		||||
    }; f"
 | 
			
		||||
 | 
			
		||||
    # Inspired by, then evolved from:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,6 @@ 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;
 | 
			
		||||
| 
						 | 
				
			
			@ -34,11 +28,8 @@ function display_parts() {
 | 
			
		|||
    local email="$3";
 | 
			
		||||
    local sigkey="$4";
 | 
			
		||||
 | 
			
		||||
    if [ ! -z "$identity" ]; then
 | 
			
		||||
        printf "[$identity] ";
 | 
			
		||||
    fi
 | 
			
		||||
    printf "$name <$email>";
 | 
			
		||||
    if [ ! -z "$sigkey" ]; then
 | 
			
		||||
    printf "[$identity] $name <$email>";
 | 
			
		||||
    if [ ! -z $sigkey ]; then
 | 
			
		||||
        printf " (signing key: $sigkey)";
 | 
			
		||||
    fi
 | 
			
		||||
    printf "\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +128,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, consider using the include subcommand instead.";
 | 
			
		||||
            echo "If you wish for that be the case, you can manually include the identity in your local git config like so:";
 | 
			
		||||
            echo;
 | 
			
		||||
            echo "[include]";
 | 
			
		||||
            echo "    path = ~/$no_home_identities/<identity>"
 | 
			
		||||
| 
						 | 
				
			
			@ -153,47 +144,9 @@ 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 "" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)";
 | 
			
		||||
            display_parts "current" "$(git config user.name)" "$(git config user.email)" "$(git config user.signingKey)";
 | 
			
		||||
        else
 | 
			
		||||
            get_identity "$2";
 | 
			
		||||
            display_identity "$identity";
 | 
			
		||||
| 
						 | 
				
			
			@ -210,8 +163,7 @@ 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 "    include: Includes the identity file in your local git config"
 | 
			
		||||
        echo "    show: Show a saved identity or the identity that's currently effective";
 | 
			
		||||
        echo "    show: Show a saved identity or the identity of the current repo";
 | 
			
		||||
        echo "    list: List all saved identities";
 | 
			
		||||
        exit 1;
 | 
			
		||||
    ;;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue