Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 949 forks source link

how to reference another virtualenv plugin? #1392

Open okakaino opened 4 years ago

okakaino commented 4 years ago

Hi, thanks for the hard work first.

I wanted to show virtualenv on my prompt, and I just found that as long as "virtualenv" is included here:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(virtualenv context dir vcs)

virtualenv always displays, no matter whether I enable oh-my-zsh virtualenv plugin or not

plugins=(git pip python)

After long time of research and grep-ing, I found that virtualenv segment is determined in powerlevel9k.zsh-theme file:

prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV"

[[ -z "$virtualenv_path" ]] && return

"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "${virtualenv_path:t}" 'PYTHON_ICON' }

so how virtualenv displays is pretty fixed here, it is not asking any other plugin for the appearance. But my system is configured a little differently, so the default value is not accurate, and I'm not able to use my own plugin to determine how I want to display my virtual environment name, is this on purpose? How can I display the way I want, please?

romkatv commented 4 years ago

If I may ask, how do you want virtualenv to be displayed?

okakaino commented 4 years ago

If I may ask, how do you want virtualenv to be displayed?

As defined in

${virtualenv_path:t}

the trailing folder name of virtualenv_path is used as the virtual environment, but my folder structure is like

Screen Shot 2020-01-08 at 11 54 53 PM

where >>test<< is what I want to show on prompt, but powerlevwl9k displays venv

I know I can replace

${virtualenv_path:t}

with

${virtualenv_path:h:t}

but is there a way to let powerlevel9k NOT to decide what to show as virtualenv, but surrender the ability to plugins like Autoswitch Python Virtualenv or virtualenv?

romkatv commented 4 years ago

Thanks for the helpful explanation. This is very reasonable. As far as I know, all users prefer what you want over the behavior of powerlevel9k.

but is there a way to let powerlevel9k NOT to decide what to show

There is no way to do what you want in powerlevel9k.