From 00c2c61e3b769545a03380eec9cd8067b67d49e1 Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Mon, 4 Dec 2017 12:01:07 -0800 Subject: [PATCH] python-info: provide python version info for theming Closes #1173 Closes #958 --- modules/python/README.md | 4 ++++ modules/python/functions/python-info | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/modules/python/README.md b/modules/python/README.md index 900158d..6860f2b 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -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 ------- diff --git a/modules/python/functions/python-info b/modules/python/functions/python-info index ccca994..e5eebc1 100644 --- a/modules/python/functions/python-info +++ b/modules/python/functions/python-info @@ -11,6 +11,8 @@ local virtualenv_format local virtualenv_formatted +local version_format +local version_formatted # Clean up previous $python_info. unset python_info @@ -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 + # }