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.
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function _hostname-color {
|
|
|
|
case "$(whoami)" in
|
|
|
|
william) echo $blue;;
|
|
|
|
buddy) echo $blue;;
|
|
|
|
root) echo $bred;;
|
|
|
|
*) echo $purple;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
# display hostname
|
|
|
|
PS1="\[$green\]"'\u'"\[$yellow\] "
|
|
|
|
PS1="$PS1\[$(_hostname-color)\]"'$(_hostname-show)'""
|
|
|
|
# display separator
|
|
|
|
PS1="$PS1\[$yellow\] "
|
|
|
|
# display current path
|
|
|
|
PS1="$PS1\[$green\]\w "
|
|
|
|
# display git branch
|
|
|
|
PS1="$PS1\[$bblack\]"'$(parse_git_branch)'
|
|
|
|
# display git status
|
|
|
|
PS1="$PS1\[$yellow\]"'$(parse_git_status) '
|
|
|
|
# display date
|
|
|
|
PS1="$PS1\[$purple\]\D{%F %I:%M%P} "
|
|
|
|
PS1="$PS1\[$color_off\]\nλ "
|
|
|
|
|
|
|
|
function parse_git_status {
|
|
|
|
if [[ $(git status 2> /dev/null | wc -l) -eq 0 ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(git status 2> /dev/null | grep -E "working tree|directory clean" | wc -l) -eq 0 ]]; then
|
|
|
|
echo ' ∓'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _hostname-show {
|
|
|
|
hostname -s | tr '[A-Z]' '[a-z]'
|
|
|
|
}
|
|
|
|
|
|
|
|
function parse_git_branch {
|
|
|
|
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
|
|
|
}
|