mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-07-01 02:19:25 +00:00
[Fix #248] Replace virtualenv_info with python-info
Conflicts: modules/python/README.md
This commit is contained in:
@ -44,6 +44,17 @@ convenient shell functions to create, switch, and manage them.
|
||||
Install virtualenvwrapper and set [`$WORKON_HOME`][4] to the path where virtual
|
||||
environments will be stored.
|
||||
|
||||
### Theming
|
||||
|
||||
To display the name of the current virtual enviroment in a prompt, define the
|
||||
following style in the `prompt_theme_setup` function.
|
||||
|
||||
# %v - virtualenv name.
|
||||
zstyle ':omz:module:python' virtualenv 'virtualenv:%v'
|
||||
|
||||
Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call
|
||||
`python-info` in the `prompt_theme_preexec` hook function.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
@ -59,6 +70,12 @@ Aliases
|
||||
- `pyzu` updates itself to the latest version.
|
||||
- `pyzx` uninstalls Python versions.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `python-info` exposes information about the Python environment via the
|
||||
`$python_info` associative array.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
|
21
modules/python/functions/python-info
Normal file
21
modules/python/functions/python-info
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# Displays Python information.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local virtualenv_format
|
||||
local virtualenv_formatted
|
||||
|
||||
# Clean up previous $python_info.
|
||||
unset python_info
|
||||
typeset -gA python_info
|
||||
|
||||
# Format virtualenv.
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
zstyle -s ':omz:module:python' virtualenv 'virtualenv_format'
|
||||
zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}"
|
||||
python_info[virtualenv]="$virtualenv_formatted"
|
||||
fi
|
||||
|
@ -24,6 +24,8 @@ fi
|
||||
|
||||
# Load virtualenvwrapper into the shell session.
|
||||
if [[ -n "$WORKON_HOME" ]] && (( $+commands[virtualenvwrapper.sh] )); then
|
||||
# Disable the virtualenv prompt.
|
||||
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
source "$commands[virtualenvwrapper.sh]"
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user