fiddling with own prompt

This commit is contained in:
Thomas Ruoff
2017-08-18 00:11:53 +02:00
committed by Thomas Ruoff
parent 0331a6f779
commit 7a7d75614c

View File

@@ -1,9 +1,21 @@
# modify the prompt to contain git branch name if applicable
git_prompt_info() {
current_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
if [[ -n $current_branch ]]; then
echo " %{$fg_bold[green]%}$current_branch%{$reset_color%}"
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
precmd() {
vcs_info
}
setopt promptsubst
last_exit_code() {
echo "%{$fg[red]%}%(?..[%?] )%{$reset_color%}"
}
user_on_host() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%{$fg_bold[yellow]%}%n@%m%{$reset_color%}"
fi
}
setopt promptsubst
PS1='${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%c%{$reset_color%}$(git_prompt_info) %# '
PS1='$(user_on_host)% > '
RPS1='$(last_exit_code) %{$fg_bold[yellow]%}${vcs_info_msg_0_}%{$reset_color%}%{$fg_bold[blue]%}%~%{$reset_color%}'