commit 638000c9eec90fc2571a40cb9de5761cd4521455 parent 2f06904f87712c415d5cb748bce98849f2e22d36 Author: hhvn <hayden@haydenvh.com> Date: Tue, 19 Jan 2021 19:04:28 +0000 .config/ksh/kshrc: update git prompt (for unpushed commits) Diffstat:
M | .config/ksh/kshrc | | | 11 | ++++++++++- |
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/.config/ksh/kshrc b/.config/ksh/kshrc @@ -29,8 +29,17 @@ _ksh_prompt(){ printf "%s" $(git branch 2>/dev/null | grep '^*' | awk '{print $2 "|"}') git diff 1>/dev/null 2>/dev/null && { git diff | grep '.' >/dev/null && tput setaf 8 || tput setaf 15 - printf "%s " $(git diff 2>/dev/null | grep -E '^(\+\+\+|---)' | sed -E 's~^[^a]*a/|^[^b]*b/~~' \ + printf "%s+" $(git diff 2>/dev/null | grep -E '^(\+\+\+|---)' | sed -E 's~^[^a]*a/|^[^b]*b/~~' \ | grep -v /dev/null | uniq | wc -l | tr -d '\n' | grep '.' || printf 0) + git log | head -n 1 | grep -v '(.*\/.*)' >/dev/null && tput setaf 14 + git log --pretty=format:"commit %h%d" | awk -v "c=0" ' + /^commit/ { + if ($3 ~ /(.*\/.*)/) { + printf("%d", c) + exit + } else c += 1 + }' + printf '^ ' } tput setaf 7 printf "%s " $(pwd | sed "s-$HOME-~-")