aboutsummaryrefslogtreecommitdiff
path: root/.zshrc
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-10-24 15:31:45 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-10-24 15:31:45 +0200
commit2667e44ca957ec75f61266305e375c011fc52cd8 (patch)
treee650843ebe02dea61f9734f44dcc6244aa211b3f /.zshrc
parent29b5b5b74d0553b98086459a614366ec320f0dfb (diff)
Add shell functions for Python venvs
It is an ugly system, and it seems it is practically inescapable. Truly an homage to the quality of the programming language and the devs who love it without question.
Diffstat (limited to '.zshrc')
-rw-r--r--.zshrc11
1 files changed, 10 insertions, 1 deletions
diff --git a/.zshrc b/.zshrc
index 63a89a1..347f3c0 100644
--- a/.zshrc
+++ b/.zshrc
@@ -126,6 +126,14 @@ function precmd() # {{{
sshd|*/sshd|mosh*) HOSTNAME_COLOR="%F{6}" ;;
esac
# }}}
+
+ # Color last directory name in case of python venv
+ PROMPT_PATH='%F{4}%~%k'
+
+ if [[ -n "$PYTHON_VENV_DIR" ]]
+ then
+ PROMPT_PATH+='%F{6}#'"$(awk -F/ '{ print $(NF-1) }' <<< "$PYTHON_VENV_DIR")"
+ fi
}
# }}}
@@ -162,7 +170,8 @@ PROMPT='%(!.%F{1}.%F{2})%n%F{8}'
PROMPT=$PROMPT'@'
PROMPT=$PROMPT'${HOSTNAME_COLOR}%M%F{8}'
PROMPT=$PROMPT':'
-PROMPT=$PROMPT'%F{4}%~%k${PGIT}'
+PROMPT=$PROMPT'${PROMPT_PATH}'
+PROMPT=$PROMPT'%k${PGIT}'
PROMPT=$PROMPT' '
PROMPT=$PROMPT'%(?.%F{7}.%F{1})${EXITCODE}%k'
PROMPT=$PROMPT' ${vi_mode}ยป%b %f${CURSOR_STYLE}'