notes/.config/bgit/bgit_log

22 lines
651 B
Bash
Executable file

#!/bin/bash
function b_log() {
tput bold & tput setaf 7
read -e -r -p "${txtblue} how many previous commits would you like to see?: ${txtyellow}" numcommits
if [[ $numcommits == "" ]]; then
numcommits=6
fi
commitarray=($(git log -$numcommits | grep commit | sed 's/commit//g'))
verbosecommits=$(git shortlog -$numcommits --reverse | sed 1d);
for ((i = 0; i < numcommits; i++)) do
j=$(echo ${i} + 1 | bc)
nextcommit=$(echo "${verbosecommits}" | head -n $j | tail -n 1)
echo -e " ${txtblue}${i}) ${txtyellow}${commitarray[$i]}${txtblue}${nextcommit}${txtblue}"
done
exit 0
}