From 78bda4fdb25b016e1fbbd4c775a9ed2dbd03cc8f Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Wed, 5 Jun 2024 20:15:24 +0200 Subject: [PATCH] bash: git* change symlink direction Signed-off-by: Michael Grote --- scripts/ghist | 43 +------------------------------------------ scripts/git_history | 43 ++++++++++++++++++++++++++++++++++++++++++- scripts/git_logs | 11 ++++++++++- scripts/glogs | 11 +---------- 4 files changed, 54 insertions(+), 54 deletions(-) mode change 100755 => 120000 scripts/ghist mode change 120000 => 100755 scripts/git_history mode change 120000 => 100755 scripts/git_logs mode change 100755 => 120000 scripts/glogs diff --git a/scripts/ghist b/scripts/ghist deleted file mode 100755 index bf88f54..0000000 --- a/scripts/ghist +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -total_commits=$(git rev-list HEAD --count) -current_commit=$total_commits - -show_commit_diff() { - if [ "$current_commit" -le "$total_commits" ] && [ "$current_commit" -ge 1 ]; then - commit_hash=$(git rev-list --reverse HEAD | sed -n "${current_commit}p") - git --no-pager show "$commit_hash" - fi -} - -while true; do - clear # Clear the terminal - show_commit_diff - - # Display navigation options - echo "-----------------------------------------------------------" - echo "Navigation: N - Next Commit, P - Previous Commit, Q - Quit" - echo "-----------------------------------------------------------" - read -r -n1 -s option - - case $option in - p|P) - # shellcheck disable=2086 - if [ $current_commit -gt 1 ]; then - ((current_commit--)) - fi - ;; - n|N) - # shellcheck disable=2086 - if [ $current_commit -lt $total_commits ]; then - ((current_commit++)) - fi - ;; - q|Q) - break - ;; - *) - echo "Invalid option" - ;; - esac -done diff --git a/scripts/ghist b/scripts/ghist new file mode 120000 index 0000000..c10c826 --- /dev/null +++ b/scripts/ghist @@ -0,0 +1 @@ +git_history \ No newline at end of file diff --git a/scripts/git_history b/scripts/git_history deleted file mode 120000 index 4182fc7..0000000 --- a/scripts/git_history +++ /dev/null @@ -1 +0,0 @@ -ghist \ No newline at end of file diff --git a/scripts/git_history b/scripts/git_history new file mode 100755 index 0000000..bf88f54 --- /dev/null +++ b/scripts/git_history @@ -0,0 +1,42 @@ +#!/bin/bash +total_commits=$(git rev-list HEAD --count) +current_commit=$total_commits + +show_commit_diff() { + if [ "$current_commit" -le "$total_commits" ] && [ "$current_commit" -ge 1 ]; then + commit_hash=$(git rev-list --reverse HEAD | sed -n "${current_commit}p") + git --no-pager show "$commit_hash" + fi +} + +while true; do + clear # Clear the terminal + show_commit_diff + + # Display navigation options + echo "-----------------------------------------------------------" + echo "Navigation: N - Next Commit, P - Previous Commit, Q - Quit" + echo "-----------------------------------------------------------" + read -r -n1 -s option + + case $option in + p|P) + # shellcheck disable=2086 + if [ $current_commit -gt 1 ]; then + ((current_commit--)) + fi + ;; + n|N) + # shellcheck disable=2086 + if [ $current_commit -lt $total_commits ]; then + ((current_commit++)) + fi + ;; + q|Q) + break + ;; + *) + echo "Invalid option" + ;; + esac +done diff --git a/scripts/git_logs b/scripts/git_logs deleted file mode 120000 index 0290127..0000000 --- a/scripts/git_logs +++ /dev/null @@ -1 +0,0 @@ -glogs \ No newline at end of file diff --git a/scripts/git_logs b/scripts/git_logs new file mode 100755 index 0000000..8fd3817 --- /dev/null +++ b/scripts/git_logs @@ -0,0 +1,10 @@ +#!/bin/bash +# https://git-scm.com/docs/pretty-formats +# https://stackoverflow.com/questions/3631005/git-log-tabular-formatting +# https://stackoverflow.com/questions/7736781/how-to-make-git-log-not-prompt-to-continue +if [ -z "$1" ]; then + ncommits=30; +else + ncommits="$1"; +fi; +git log --pretty=format:'%C(auto) %<|(16,trunc)%h %Cred %G?%Creset %<|(60,trunc)%s %<(20,trunc)%Cgreen%cr%Creset %<(15,trunc)%Cblue%an%Creset %Cred%D' --graph --all -"$ncommits" diff --git a/scripts/glogs b/scripts/glogs deleted file mode 100755 index 8fd3817..0000000 --- a/scripts/glogs +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# https://git-scm.com/docs/pretty-formats -# https://stackoverflow.com/questions/3631005/git-log-tabular-formatting -# https://stackoverflow.com/questions/7736781/how-to-make-git-log-not-prompt-to-continue -if [ -z "$1" ]; then - ncommits=30; -else - ncommits="$1"; -fi; -git log --pretty=format:'%C(auto) %<|(16,trunc)%h %Cred %G?%Creset %<|(60,trunc)%s %<(20,trunc)%Cgreen%cr%Creset %<(15,trunc)%Cblue%an%Creset %Cred%D' --graph --all -"$ncommits" diff --git a/scripts/glogs b/scripts/glogs new file mode 120000 index 0000000..c90c48d --- /dev/null +++ b/scripts/glogs @@ -0,0 +1 @@ +git_logs \ No newline at end of file