1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-23 02:18:00 +00:00
prezto/modules/python/functions/python-info

44 lines
1.2 KiB
Plaintext
Raw Normal View History

#
2012-09-07 03:17:38 +00:00
# Exposes information about the Python environment via the $python_info
# associative array.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
# Patrick Bos <egpbos@gmail.com>
#
# function python-info {
local virtualenv_format
local virtualenv_formatted
local version_format
local version_formatted
# Clean up previous $python_info.
unset python_info
typeset -gA python_info
# Format virtualenv.
if [[ -n "$VIRTUAL_ENV" ]]; then
2012-10-02 02:02:47 +00:00
zstyle -s ':prezto:module:python:info:virtualenv' format 'virtualenv_format'
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
if (( $+commands[python] )); then
zstyle -s ':prezto:module:python:info:version' format 'version_format'
if [[ -n "$version_format" ]]; then
zformat -f version_formatted "$version_format" "v:${$(python3 --version)#Python }"
python_info[version]="$version_formatted"
fi
fi
# }