본문 바로가기
카테고리 없음

ZSH 프롬프트 가상환경 보이게 설정

by Z0e 2025. 3. 5.

 

 

 

 

`~/.zshrc` 에 추가

 

zsh_virtualenv_prompt() {
    # If not in a virtualenv, print nothing
    [[ "$VIRTUAL_ENV" == "" ]] && return

    # Distinguish between the shell where the virtualenv was activated
    # and its children
    local venv_name="${VIRTUAL_ENV##*/}"
    if typeset -f deactivate >/dev/null; then
        echo "[%F{green}${venv_name}%f] "
    else
        echo "<%F{green}${venv_name}%f> "
    fi
}

setopt PROMPT_SUBST PROMPT_PERCENT

# Display a "we are in a virtualenv" indicator that works in child shells too
VIRTUAL_ENV_DISABLE_PROMPT=1
RPS1='$(zsh_virtualenv_prompt)'

 

 

https://virtualenvwrapper.readthedocs.io/en/latest/tips.html