[Fix #248] Replace virtualenv_info with python-info
Conflicts: modules/python/README.md
This commit is contained in:
parent
1057801208
commit
98c545a102
@ -12,12 +12,6 @@
|
|||||||
# http://i.imgur.com/HyRvv.png
|
# http://i.imgur.com/HyRvv.png
|
||||||
#
|
#
|
||||||
|
|
||||||
function virtualenv_info {
|
|
||||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
|
||||||
print "(${VIRTUAL_ENV:t}) "
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_steeef_precmd {
|
function prompt_steeef_precmd {
|
||||||
# Check for untracked files or updated submodules since vcs_info does not.
|
# Check for untracked files or updated submodules since vcs_info does not.
|
||||||
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
||||||
@ -29,6 +23,10 @@ function prompt_steeef_precmd {
|
|||||||
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
||||||
|
|
||||||
vcs_info 'prompt'
|
vcs_info 'prompt'
|
||||||
|
|
||||||
|
if (( $+functions[python-info] )); then
|
||||||
|
python-info
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt_steeef_setup {
|
function prompt_steeef_setup {
|
||||||
@ -83,10 +81,13 @@ function prompt_steeef_setup {
|
|||||||
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
||||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||||
|
|
||||||
|
# Set python-info parameters.
|
||||||
|
zstyle ':omz:module:python' virtualenv '(%v)'
|
||||||
|
|
||||||
# Define prompts.
|
# Define prompts.
|
||||||
PROMPT="
|
PROMPT="
|
||||||
${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'"
|
${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'"
|
||||||
"'$(virtualenv_info)'"$ "
|
"'$python_info[virtualenv]'"$ "
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_steeef_setup "$@"
|
prompt_steeef_setup "$@"
|
||||||
|
@ -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
|
Install virtualenvwrapper and set [`$WORKON_HOME`][4] to the path where virtual
|
||||||
environments will be stored.
|
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
|
Aliases
|
||||||
-------
|
-------
|
||||||
|
|
||||||
@ -59,6 +70,12 @@ Aliases
|
|||||||
- `pyzu` updates itself to the latest version.
|
- `pyzu` updates itself to the latest version.
|
||||||
- `pyzx` uninstalls Python versions.
|
- `pyzx` uninstalls Python versions.
|
||||||
|
|
||||||
|
Functions
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `python-info` exposes information about the Python environment via the
|
||||||
|
`$python_info` associative array.
|
||||||
|
|
||||||
Authors
|
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.
|
# Load virtualenvwrapper into the shell session.
|
||||||
if [[ -n "$WORKON_HOME" ]] && (( $+commands[virtualenvwrapper.sh] )); then
|
if [[ -n "$WORKON_HOME" ]] && (( $+commands[virtualenvwrapper.sh] )); then
|
||||||
|
# Disable the virtualenv prompt.
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
source "$commands[virtualenvwrapper.sh]"
|
source "$commands[virtualenvwrapper.sh]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user