You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
938 B
Bash

#!/usr/bin/env bash
if [[ -z ${STARSHIP_SESSION_KEY} ]] ; then
return
fi
color_off='\e[0m'
green='\e[0;32m'
yellow='\e[0;33m'
blue='\e[0;34m'
purple='\e[0;35m'
bblack='\e[1;30m'
# display hostname
PS1="\[$green\]"'\u '"\[$blue\]"'$(hostname -s | tr ':A-Z:' ':a-z:') '"\[$green\]\w "
if command -v git &> /dev/null ; then
function parse_git_status {
if [[ $(git status 2> /dev/null | wc -l) -eq 0 ]]; then
return
fi
if [[ $(git status 2> /dev/null | grep -c "working tree clean") -eq 0 ]]; then
echo ' ∓'
fi
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
# display git branch
PS1="$PS1\[$bblack\]"'$(parse_git_branch)'
# display git status
PS1="$PS1\[$yellow\]"'$(parse_git_status) '
fi
# display date
PS1="$PS1\[$purple\]\D{%F %I:%M%P} "
PS1="$PS1\[$color_off\]\nλ "