Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

[Enhancement] Show python version of conda virtual environment #1053

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions segments/conda_env.p9k
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
################################################################
# @title powerlevel9k Segment - Python Environment
# @source [powerlevel9k](https://github.com/bhilburn/powerlevel9k)
##

################################################################
# Register segment
# Parameters:
# segment_name context background foreground Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont
#   🐍 
p9k::register_segment "CONDA_ENV" "" "blue" "$DEFAULT_COLOR" '' $'\uE63C' $'\uE63C' $'\U1F40D' $'\uE73C '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
p9k::register_segment "CONDA_ENV" "" "blue" "$DEFAULT_COLOR" '' $'\uE63C' $'\uE63C' $'\U1F40D' $'\uE73C '
p9k::register_segment "PYTHON_VERSION" "" "blue" "$DEFAULT_COLOR" '' $'\uE63C' $'\uE63C' $'\U1F40D' $'\uE73C '


################################################################
# Register segment default values
p9k::set_default P9K_CONDA_ENV_PROMPT_ALWAYS_SHOW false

################################################################
# @description
# Display the current active python version

prompt_conda_env() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this segment to something like prompt_python_version.. This is what it does, right? Or is it in it's current form related to conda?

if [["${P9K_PYENV_PROMPT_ALWAYS_SHOW}" == "true" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is meaningless, isn't it? If you do not set P9K_PYENV_PROMPT_ALWAYS_SHOW to true, you'll never see the segment. This would be the same, as removing it from your configuration..

conda_py_version=$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
conda_py_version=$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
local conda_py_version=$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')

p9k::prepare_segment "$0" "" $1 "$2" $3 "${conda_py_version}"
fi
}