Skip to content

Commit

Permalink
python-info: provide python version info for theming
Browse files Browse the repository at this point in the history
  • Loading branch information
belak authored and Ayrton Araujo committed May 24, 2018
1 parent 911e155 commit d9a936b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ following style in the `prompt_name_setup` function.
Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call
`python-info` in the `prompt_name_preexec` hook function.

Similarly, you can use `:prezto:module:python:info:version:format` with `%v` for
the version and add `$python_info[version]` to your prompt for the current
python version/

Authors
-------

Expand Down
8 changes: 8 additions & 0 deletions modules/python/functions/python-info
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

local virtualenv_format
local virtualenv_formatted
local version_format
local version_formatted

# Clean up previous $python_info.
unset python_info
Expand All @@ -30,4 +32,10 @@ if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
python_info[virtualenv]="$virtualenv_formatted"
fi

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

# }

0 comments on commit d9a936b

Please sign in to comment.