From 3ea8d23b01ce81fb30e3080694462a816cb6ff31 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Wed, 11 May 2016 17:37:40 +0200 Subject: [PATCH] Added conda virtualenv support to python module. --- modules/python/functions/python-info | 8 ++++++++ modules/python/init.zsh | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/modules/python/functions/python-info b/modules/python/functions/python-info index 6a8c7589..20e3d4d9 100644 --- a/modules/python/functions/python-info +++ b/modules/python/functions/python-info @@ -4,6 +4,7 @@ # # Authors: # Sorin Ionescu +# Patrick Bos # local virtualenv_format @@ -19,3 +20,10 @@ if [[ -n "$VIRTUAL_ENV" ]]; then zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}" python_info[virtualenv]="$virtualenv_formatted" fi + +# Do the same for Conda virtual environments +if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format' + zformat -f virtualenv_formatted "$virtualenv_format" "v:${CONDA_DEFAULT_ENV:t}" + python_info[virtualenv]="$virtualenv_formatted" +fi diff --git a/modules/python/init.zsh b/modules/python/init.zsh index 458253b2..50121ff1 100644 --- a/modules/python/init.zsh +++ b/modules/python/init.zsh @@ -4,6 +4,7 @@ # Authors: # Sorin Ionescu # Sebastian Wiesner +# Patrick Bos # # Load manually installed pyenv into the shell session. @@ -46,6 +47,14 @@ if (( $? && $+commands[virtualenvwrapper.sh] )); then source "$commands[virtualenvwrapper.sh]" fi +# Load conda into the shell session, if requested +zstyle -T ':prezto:module:python' conda-init +if (( $? && $+commands[conda] )); then + if (( $(conda ..changeps1) )); then + echo "To make sure Conda doesn't change your prompt (should do that in the prompt module) run:\n conda config --set changeps1 false" + fi +fi + # # Aliases #