blob: b9e8bc19663d4e17fd9804aa5f5426733a22ccd7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# --rcfile skips the system bashrc, so load it ourselves: it sets PATH for
# Nix/nix-darwin, Homebrew shellenv hooks, and other system-wide tools.
for _rc in /etc/bashrc /etc/bash.bashrc; do
[[ -f $_rc ]] && { source "$_rc"; break; }
done
unset _rc
# User configuration next; this prompt is scoped to Ducky.
[[ -f ~/.bashrc ]] && source ~/.bashrc
_ducky_prompt() {
local status=$? branch
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || branch=''
PS1=$'\n\[\e[35m\]╭─ '
PS1+='\[\e[0m\]\w'
_ducky_branch=$branch
[[ -n $branch ]] && PS1+=' \[\e[36m\]⎇ ${_ducky_branch}'
[[ $status -ne 0 ]] && PS1+=" \[\e[31m\]${status}"
PS1+=$'\n\[\e[35m\]╰─❯ \[\e[0m\]'
}
# Keep other prompt hooks, then set Ducky's prompt last.
if declare -p PROMPT_COMMAND 2>/dev/null | grep -q 'declare -a'; then
PROMPT_COMMAND+=(_ducky_prompt)
else
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }_ducky_prompt"
fi
|