From 8e1476e7b3c97adee9c38e2f019c8f8470621f7f Mon Sep 17 00:00:00 2001 From: lhark Date: Tue, 10 Jul 2018 15:35:05 -0400 Subject: [PATCH] [zshrc] Fix virtualenv prompt and git colors --- prompt | 10 +++++----- zshrc | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/prompt b/prompt index 6e53c8d..017f634 100644 --- a/prompt +++ b/prompt @@ -43,10 +43,10 @@ last_status () { } virtual_env() { - local prefix=" %{$fg_bold[green]%}(%{%b$fg[green]%}" + local prefix="%{$fg_bold[green]%}(%{%b$fg[green]%}" local suffix="%{$reset_color$fg_bold[green]%})%{$reset_color%}" [[ -n ${VIRTUAL_ENV} ]] || return - printf "${prefix}${VIRTUAL_ENV:t}${suffix}" + printf '%s' "${prefix}${VIRTUAL_ENV:t}${suffix}" } prompt_chars() { @@ -54,7 +54,7 @@ prompt_chars() { if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then local git_char="%{$fg_no_bold[blue]%}±%{$reset_color%}" fi - printf "%s" "${_GIT_CHAR}$(last_status) $(color_prompt_char)" + printf '%s' "${_GIT_CHAR}$(last_status) $(color_prompt_char)" } charge_batterie() { @@ -102,8 +102,8 @@ prompt_msg () { git_network_unreachable) msg="Can't reach rc git repo";; update_sys*) - nb_pkg=$(printf "$line" | grep -o '[0-9]*' | head -n 1) - msg="Update ready for the system. $nb_pkg new package$([ $nb_pkg -gt 1 ] && printf "s")";; + nb_pkg=$(printf '%s' "$line" | grep -o '[0-9]*' | head -n 1) + msg="Update ready for the system. $nb_pkg new package$([ $nb_pkg -gt 1 ] && printf 's')";; *) msg="";; esac diff --git a/zshrc b/zshrc index da15b5d..d6e3da2 100644 --- a/zshrc +++ b/zshrc @@ -34,6 +34,9 @@ export PKG_CONFIG_PATH="/opt/ros/indigo/lib/pkgconfig:$PKG_CONFIG_PATH" RC_PATH=$(dirname "$(readlink -f ${(%):-%x})") # Import utility functions +# Colors needed for the prompt definition +autoload -U colors +colors . "$RC_PATH/functions" . "$RC_PATH/aliases" . "$RC_PATH/prompt" @@ -140,7 +143,7 @@ zstyle ':completion:*' cache-path ~/.zs ###################### zmodload zsh/complist -autoload -U compinit promptinit colors +autoload -U compinit promptinit compinit colors autoload -U zsh-mime-setup