From b96ee9511fdc24a550561bfb5b3fa3848340cf0a Mon Sep 17 00:00:00 2001 From: crater2150 Date: Tue, 14 May 2019 14:44:42 +0200 Subject: [PATCH] Change venv prompt to include parent dir, if venv dir is called "venv" only --- modules/prompt/init | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/prompt/init b/modules/prompt/init index 2e4cbec..141dd50 100644 --- a/modules/prompt/init +++ b/modules/prompt/init @@ -97,7 +97,13 @@ function setprompt() { [[ -w $PWD ]] && infoline+=( ${pathcolor} ) || infoline+=( ${ropathcolor} ) infoline+=( "${PVPREFIX} %(5~|%-1~/.../|)%3~ ${PVSUFFIX}${rpscolor}${PR_HBAR}" ) - [[ -n "$VIRTUAL_ENV" ]] && infoline+=( "${usercolor}${PVPREFIX}venv: ${VIRTUAL_ENV:t}${PVSUFFIX}${rpscolor}" ) + if [[ -n "$VIRTUAL_ENV" ]] then + local venvname=${VIRTUAL_ENV:t} + if [[ $venvname == "venv" ]]; then + venvname=${VIRTUAL_ENV:h:t}/${VIRTUAL_ENV:t} + fi + infoline+=( "${usercolor}${PVPREFIX}venv: ${venvname}${PVSUFFIX}${rpscolor}" ) + fi [[ -n "$CONDA_DEFAULT_ENV" ]] && infoline+=( "${usercolor}${PVPREFIX}conda: ${CONDA_DEFAULT_ENV}${PVSUFFIX}${rpscolor}" ) # Username & host @@ -107,7 +113,7 @@ function setprompt() { i_width=${(S)infoline//\%\{*\%\}} # search-and-replace color escapes i_width=${(%)i_width} # expand all escapes and count the chars i_width=${#i_width} # expand all escapes and count the chars - ((i_width += 1)) # workaround off by one, unknown reason + ((i_width += 2)) # workaround off by one, unknown reason if [[ "$PROMPT_UNICODE" = "yes" ]]; then filler="${rpscolor}${(l:$(( $COLUMNS - $i_width + 2))::─:)}"