dotfiles/dotlib/prompt.sh

53 lines
1.1 KiB
Bash

read -r month day < <(date "+%m %d")
if (( 10#$month == 3 && 10#$day < 18 )); then
if (( 17 - 10#$day == 0 )); then
printf "Happy Saint Patrick's day!\n"
else
printf "Only %d days left until Saint Patrick's day!\n" "$(( 17 - 10#$day ))"
fi
prompt_sym=🍀
elif (( 10#$month == 10 )); then
if (( 31 - 10#$day == 0 )); then
printf 'Have a spooky halloween!\n'
else
printf 'Only %d days left until Halloween!\n' "$(( 31 - 10#$day ))"
fi
prompt_sym=🎃
elif (( 10#$month == 12 && 10#$day < 26 )); then
if (( 25 - 10#$day == 0 )); then
printf 'Merry Christmas!\n'
else
printf 'Only %d days left until Christmas!\n' "$(( 25 - 10#$day ))"
fi
prompt_sym=🌲
fi
setup-prompt() {
local cmd
if [[ -v prompt_cmds[@] ]]; then
for cmd in "${prompt_cmds[@]}"; do
"$cmd"
done
fi
if [[ -d .git ]]; then
git_branch="$(command git branch --show-current) "
else
git_branch=""
fi
}
PROMPT_COMMAND=setup-prompt
PS1='\w $git_branch'
if [[ -v SSH_CLIENT ]]; then
PS1+='${HOSTNAME-"$(hostname)"} '
fi
PS1+='${prompt_sym-λ} '