about summary refs log tree commit diff
path: root/.config/zsh/prompt.zsh
blob: eecc39e5f71ec9e2be1ae9ed429e7e89ab513fb3 (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
# prompt
setopt prompt_subst

autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' actionformats '%F{purple}[%F{green}%b%F{olive}|%F{red}%a%F{purple}]%f '
zstyle ':vcs_info:*' formats '%F{purple}[%F{green}%b%F{purple}]%f '

get_git () {
	[[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]] && vcs_info || vcs_info_msg_0_=""
}
autoload -Uz add-zsh-hook
add-zsh-hook precmd get_git

user="%n"
if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then
	user+="@%M"
fi
last_status="%(?.%F{green}%#.%F{red}%?)%f"
location="%F{blue}%3~%f"
PROMPT="[$user:$location] "'${vcs_info_msg_0_}'"${last_status} "
unset user
unset last_status
unset location