mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
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
This commit is contained in:
parent
b6ea876971
commit
ba794028ab
1 changed files with 14 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue