From: Samir Benmendil Date: Mon, 2 Sep 2019 11:59:34 +0000 (+0100) Subject: zsh: add virtualenv prompt X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/f11b95c457d4a1b7a3bd1625a12c1ee848a3ffe1?ds=sidebyside zsh: add virtualenv prompt --- diff --git a/zsh/lib/prompt.zsh b/zsh/lib/prompt.zsh index 683fab4..c8ca45b 100644 --- a/zsh/lib/prompt.zsh +++ b/zsh/lib/prompt.zsh @@ -6,7 +6,7 @@ hostcolor=green [[ $(hostname) == "tardis" ]] && hostcolor=red precmd() { - PROMPT='%T %n@%{$fg[$hostcolor]%}%m%(1j. $fg_bold[white]↵%{$fg_bold[red]%}%j.)%{$reset_color%}%-0>..>$(git_prompt_status)%>> + PROMPT='%T $(virtualenv_prompt)%n@%{$fg[$hostcolor]%}%m%(1j. $fg_bold[white]↵%{$fg_bold[red]%}%j.)%{$reset_color%}%-0>..>$(git_prompt_status)%>> %(?..%{$fg_bold[white]%}%?)%{$reset_color%}$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} ' RPROMPT='%{$fg[green]%}%~%{$reset_color%}' } @@ -108,6 +108,14 @@ git_prompt_status() { echo $git_status } +function virtualenv_prompt() { + if [[ -z $VIRTUAL_ENV ]] then + echo "" + else + echo "(${VIRTUAL_ENV##*/}) " + fi +} + function print_if_fits() { local zero length