dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit d26a8018f60c72f00895e7436608d27272ea93fd
parent 638000c9eec90fc2571a40cb9de5761cd4521455
Author: hhvn <hayden@haydenvh.com>
Date:   Tue, 19 Jan 2021 19:32:11 +0000

.config/ksh/kshrc .config/ksh/prompt: move _ksh_prompt() into a seperate file

Diffstat:
A.config/ksh/prompt | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/.config/ksh/prompt b/.config/ksh/prompt @@ -0,0 +1,31 @@ +#!/bin/ksh + +_ksh_prompt(){ + errorcode=$1 + tput setaf 10 + [ $errorcode -eq 0 ] && tput setaf 15 || tput setaf 10 + printf "%s " $errorcode + tput setaf 5 + printf "%s " $(whoami) + tput setaf 3 + 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/~~' \ + | 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-~-") + tput setaf 7 + printf "$ " + tput sgr0 +}