integrate virtualenv indicator into custom zsh prompt
The zsh prompt looks broken when a virtualenv is activated. This
PR adds better support for virtual environments that use the
VIRTUAL_ENV environment variable.
John Grese
3 years ago
54 | 54 | debian_chroot=$(cat /etc/debian_chroot) |
55 | 55 | fi |
56 | 56 | |
57 | # override default virtualenv indicator in prompt | |
58 | export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
59 | venv_info() { | |
60 | [ $VIRTUAL_ENV ] && echo "(%B%F{reset}$(basename $VIRTUAL_ENV)%b%F{%(#.blue.green)})" | |
61 | } | |
62 | ||
57 | 63 | # set a fancy prompt (non-color, unless we know we "want" color) |
58 | 64 | case "$TERM" in |
59 | 65 | xterm-color|*-256color) color_prompt=yes;; |
76 | 82 | fi |
77 | 83 | |
78 | 84 | if [ "$color_prompt" = yes ]; then |
79 | PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)──}(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} ' | |
85 | PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)──}$(venv_info)(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} ' | |
80 | 86 | RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)' |
81 | 87 | |
82 | 88 | # enable syntax-highlighting |