From 205ffe0cf4c7b839d9bd09454244a3be5eddc082 Mon Sep 17 00:00:00 2001 From: Starfall Date: Tue, 2 Feb 2021 14:56:43 -0600 Subject: zsh: use vcs_info for branch name in prompt --- .config/zsh/.zshrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index edab06a..8822bfc 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -95,16 +95,22 @@ function spacetotab () { # prompt # TODO maybe just use someone else's theme altogether -# TODO git integration was useful - port something from belak/zsh-utils or ohmyzsh # TODO location should control its length a little better # TODO only color the last segment of the path (pwd) +setopt prompt_subst +autoload -Uz vcs_info +zstyle ':vcs_info:*' actionformats '%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats '%F{5}[%F{2}%b%F{5}]%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' +precmd () { vcs_info } + 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] $last_status " +PROMPT="[$user:$location] "'${vcs_info_msg_0_}'"${last_status} " unset user unset last_status unset location -- cgit