From 426f15e20d2acd0114500a15146b6d505acdf1b6 Mon Sep 17 00:00:00 2001 From: mayuroks Date: Sat, 29 Aug 2015 08:13:21 +0530 Subject: [PATCH] python_info[version] will show python version in the format "py-3.4.1" (without the quotes.) Also changed prompt_name_preexec to prompt_name_precmd. prompt_name_precmd is executed before the prompt is loaded. This makes loading the prompt with python info sort of "proactive". --- modules/python/README.md | 4 +++- modules/python/functions/python-info | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/python/README.md b/modules/python/README.md index d9497d6f..9b6612e7 100644 --- a/modules/python/README.md +++ b/modules/python/README.md @@ -74,6 +74,8 @@ Functions Theming ------- + - `python_info[virtualenv]` exposes virtualenv name + - `python_info[version]` exposes virtualenv python version (eg. py-3.4.1, py-2.7.6) To display the name of the current virtual enviroment in a prompt, define the following style in the `prompt_name_setup` function. @@ -82,7 +84,7 @@ following style in the `prompt_name_setup` function. zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v' Then add `$python_info[virtualenv]` to `$PROMPT` or `$RPROMPT` and call -`python-info` in the `prompt_name_preexec` hook function. +`python-info` in the `prompt_name_precmd` hook function. Authors ------- diff --git a/modules/python/functions/python-info b/modules/python/functions/python-info index 6a8c7589..0fdf7534 100644 --- a/modules/python/functions/python-info +++ b/modules/python/functions/python-info @@ -18,4 +18,6 @@ if [[ -n "$VIRTUAL_ENV" ]]; then 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" + PY_VERSION=`python -V 2>&1` + python_info[version]="py-"$PY_VERSION[(w)2] fi