.bashrc.d/l1/promptrc
Johannes Randerath 16a147d988 Inititial commit
2024-05-06 21:04:37 +02:00

26 lines
577 B
Plaintext

function is_git_repo() {
if [ -d .git ]; then
return 0;
fi
return 1;
}
function get_git_branch() {
if is_git_repo ; then
printf "($(git status 2> /dev/null | awk '/branch /{print $3; exit;}'))"
fi
}
function get_git_up2date() {
if is_git_repo ; then
if [ $(git status 2>/dev/null | awk '/nothing to commit, working tree clean/{print $1}') ]; then
printf ${grn_fn};
else
printf ${red_fn};
fi
fi
}
PS1=${ylw}'\u:'${blu}'\W '${wht}'$(get_git_branch)\[$(get_git_up2date)\]\$ '${clr}