2021-01-28 23:23:03 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2021-03-23 20:18:34 +00:00
|
|
|
# hide EOL sign ('%')
|
|
|
|
export PROMPT_EOL_MARK=""
|
|
|
|
|
2021-01-28 23:23:03 +00:00
|
|
|
# Color definition
|
2021-04-14 18:40:33 +00:00
|
|
|
GREEN="%F{047}"
|
2021-01-28 23:23:03 +00:00
|
|
|
RED="%F{196}"
|
|
|
|
ORANGE="%F{214}"
|
2021-04-14 18:40:33 +00:00
|
|
|
BLUE="%F{027}"
|
2021-01-28 23:23:03 +00:00
|
|
|
LBLUE="%F{075}"
|
|
|
|
PURPLE="%F{105}"
|
|
|
|
RESET="%f"
|
|
|
|
|
|
|
|
git_prompt() {
|
2021-01-28 23:39:51 +00:00
|
|
|
ref=$(command git symbolic-ref HEAD 2> /dev/null) || ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
|
2021-01-29 09:38:37 +00:00
|
|
|
echo -n " $ORANGE${ref#refs/heads/}"
|
2021-01-28 23:23:03 +00:00
|
|
|
|
|
|
|
if [ ! -z "$(git status --short)" ]; then
|
2021-01-28 23:39:51 +00:00
|
|
|
echo "$RED+"
|
2021-01-28 23:23:03 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-01-28 23:39:51 +00:00
|
|
|
|
2021-03-23 20:18:34 +00:00
|
|
|
setopt promptsubst # enable command substitution in prompt
|
2021-01-28 23:23:03 +00:00
|
|
|
|
|
|
|
# Primary Prompt
|
2021-04-14 18:40:33 +00:00
|
|
|
[ "$EUID" -eq 0 ] && PS1="$RED%n$RESET" || PS1="$GREEN%n$RESET" # user@machine
|
2021-04-19 08:47:00 +00:00
|
|
|
#PS1+=" $BLUE%~" # Working directory
|
|
|
|
PS1+=" $BLUE%(5~|%-1~/…/%3~|%4~)"
|
2021-01-29 09:38:37 +00:00
|
|
|
PS1+="\$(git_prompt)"
|
2021-01-28 23:23:03 +00:00
|
|
|
PS1+=" $PURPLE%(!.#.»)$RESET " # Final symbol (# or »)
|
|
|
|
|
|
|
|
# Next line prompt
|
|
|
|
PS2="$RED\ $RESET"
|
|
|
|
|
|
|
|
# Right side prompt (on error)
|
|
|
|
RPS1="%(?..$RED%? ↵$RESET)"
|
2021-04-19 08:47:00 +00:00
|
|
|
|
|
|
|
# SSH Prompt
|
|
|
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
|
|
|
PS1="$PURPLE(ssh) $RESET${PS1}"
|
|
|
|
fi
|