From d9ca9f659b528333aa40c52606c19714d18c4706 Mon Sep 17 00:00:00 2001 From: "Lockszmith (@Kateryna)" Date: Tue, 25 Feb 2025 10:05:56 -0500 Subject: [PATCH] add: git-l --- _home/private_dot_local/bin/executable_git-l | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 _home/private_dot_local/bin/executable_git-l diff --git a/_home/private_dot_local/bin/executable_git-l b/_home/private_dot_local/bin/executable_git-l new file mode 100644 index 0000000..a6cbb83 --- /dev/null +++ b/_home/private_dot_local/bin/executable_git-l @@ -0,0 +1,35 @@ +#! /usr/bin/env bash + +# Default is ~2 which will translate to '~2' +# '' and '~1' mean pretty much the same +# '~2' is one commit before it. +arg_one="${1:-}" +if [[ -z "$arg_one" ]]; then + if (git show main~2 --quiet --online 2>&1) >/dev/null; then + arg_one="~2" + elif (git show main~1 --quiet --online 2>&1) >/dev/null; then + arg_one="~1" + else + arg_one="+" + fi +fi +if [[ "$arg_one" == '+' ]]; then + [[ "${LINES-0}" -ne 0 ]] || LINES="$(tput lines)" + arg_one="-$(( (LINES-1)/3 ))" +elif [[ "$arg_one" =~ ^\.?~ ]]; then + arg_one="$(git default)${arg_one#\.}.." +fi + +git_args=( + "--abbrev-commit" "--decorate" "--graph" + "--format=%C(yellow)%h%C(reset) %C(dim cyan)[%><(14)%ar] %C(reset)%C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset) " + "$arg_one" "${@:2}" +) +if [ "$1" == "---" ]; then + git_args=("${@:2}") +fi +#ANSI_Grey "${git_args[*]}" && echo '' + +command git log "${git_args[@]}" +printf "\n" +