bash: git* change symlink direction

Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2024-06-05 20:15:24 +02:00
parent 2989151380
commit 78bda4fdb2
4 changed files with 54 additions and 54 deletions

View file

@ -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

1
scripts/ghist Symbolic link
View file

@ -0,0 +1 @@
git_history

View file

@ -1 +0,0 @@
ghist

42
scripts/git_history Executable file
View file

@ -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

View file

@ -1 +0,0 @@
glogs

10
scripts/git_logs Executable file
View file

@ -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"

View file

@ -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"

1
scripts/glogs Symbolic link
View file

@ -0,0 +1 @@
git_logs