From 7a7d75614cdcadc05558ce8cc88d75b84bcd96a3 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Fri, 18 Aug 2017 00:11:53 +0200 Subject: [PATCH] fiddling with own prompt --- zsh/configs/prompt.zsh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/zsh/configs/prompt.zsh b/zsh/configs/prompt.zsh index 3b6a42d..f1505e5 100644 --- a/zsh/configs/prompt.zsh +++ b/zsh/configs/prompt.zsh @@ -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%}'