From ba794028ab1ac909c25d10a99ef239a9369b0078 Mon Sep 17 00:00:00 2001 From: Matt Sweeney Date: Tue, 30 Apr 2013 17:10:02 -0700 Subject: [PATCH] Add prefix/suffix options to virtualenv prompt Following the pattern used in `git_prompt_info()`: https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/git.zsh#L5 Allow `virtualenv_prompt_info()` to (optionally) accept a prefix and suffix set in the theme --- plugins/virtualenv/virtualenv.plugin.zsh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh index e8458389f..934f54aa3 100644 --- a/plugins/virtualenv/virtualenv.plugin.zsh +++ b/plugins/virtualenv/virtualenv.plugin.zsh @@ -1,8 +1,20 @@ -function virtualenv_prompt_info(){ +function virtualenv_check() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n $virtualenv_path ]]; then local virtualenv_name=`basename $virtualenv_path` - printf "%s[%s] " "%{${fg[yellow]}%}" $virtualenv_name + printf "%s" $virtualenv_name + fi +} + +function virtualenv_prompt_info() { + local prefix="$ZSH_THEME_VIRTUALENV_PROMPT_PREFIX" + local suffix="$ZSH_THEME_VIRTUALENV_PROMPT_SUFFIX" + if [[ -n $(virtualenv_check) ]]; then + if [[ -n $prefix ]]; then + printf "%s%s%s" $prefix $(virtualenv_check) $suffix + else + printf "%s[%s] " "%{${fg[yellow]}%}" $(virtualenv_check) + fi fi }