2012-09-03 10:34:41 -04:00
|
|
|
#
|
2012-09-06 23:17:38 -04:00
|
|
|
# Exposes information about the Python environment via the $python_info
|
|
|
|
# associative array.
|
2012-09-03 10:34:41 -04:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2016-07-29 02:10:28 -05:00
|
|
|
local version
|
|
|
|
local version_format
|
|
|
|
local version_formatted
|
2012-09-03 10:34:41 -04:00
|
|
|
local virtualenv_format
|
|
|
|
local virtualenv_formatted
|
|
|
|
|
|
|
|
# Clean up previous $python_info.
|
|
|
|
unset python_info
|
|
|
|
typeset -gA python_info
|
|
|
|
|
2016-07-29 02:10:28 -05:00
|
|
|
if (( $+commands[pyenv] )); then
|
|
|
|
version="${"$(pyenv version)"%% *}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format version.
|
|
|
|
if [[ -n "$version" ]]; then
|
|
|
|
zstyle -s ':prezto:module:python:info:version' format 'version_format'
|
|
|
|
zformat -f version_formatted "$version_format" "v:$version"
|
|
|
|
python_info[version]="${version_formatted}"
|
|
|
|
fi
|
|
|
|
|
2012-09-03 10:34:41 -04:00
|
|
|
# Format virtualenv.
|
|
|
|
if [[ -n "$VIRTUAL_ENV" ]]; then
|
2012-10-01 22:02:47 -04:00
|
|
|
zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format'
|
2012-09-03 10:34:41 -04:00
|
|
|
zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}"
|
|
|
|
python_info[virtualenv]="$virtualenv_formatted"
|
|
|
|
fi
|