Skip to content
Open
Changes from 2 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
16 changes: 14 additions & 2 deletions themes/developer/developer.theme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,24 @@ function _omb_theme_developer__read_ruby_version {
## @var[out] REPLY
function _omb_theme_developer__readPyVersion {
local val_py=$(python --version 2>/dev/null | cut -d ' ' -f 2)
local val_uv=$(uv --version 2>/dev/null | cut -d ' ' -f 2)
local val_venv=""

## according some docs this env var just exist when a venv/uv venv is active
if [[ -n "$VIRTUAL_ENV" ]]; then
val_venv=" ($(echo "$VIRTUAL_ENV" | awk -F/ '{print $(NF-1)"/"$NF}'))"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering what happens when VIRTUAL_ENV contains a newline in the path. The above would output multiple aaa/bbb pairs. Also, what happens when VIRTUAL_ENV doesn't contain any /? It would output / + $VIRTUAL_ENV, but I'm not sure if it's the intended behavior. I'd suggest simply doing

Suggested change
if [[ -n "$VIRTUAL_ENV" ]]; then
val_venv=" ($(echo "$VIRTUAL_ENV" | awk -F/ '{print $(NF-1)"/"$NF}'))"
if [[ $VIRTUAL_ENV =~ [^/]+/[^/]+$ ]]; then
val_venv=" ($BASH_REMATCH)"

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what happens when VIRTUAL_ENV doesn't contain any /?

This hasn't been answered. Or is it ensured that it VIRTUAL_ENV contains /?

fi

if _omb_util_command_exists conda; then
local condav=$(conda env list | awk '$2 == "*" {print $1}')
val_py="conda<$condav> $val_py"
else
# Si nvm no está instalado, utilizar "njs"
val_py="py $val_py"
if _omb_util_command_exists uv; then
val_py="uv($val_uv) $val_py$val_venv"
else
# if conda and uv is not installed use "py"
val_py="py $val_py"
fi
fi
REPLY=$val_py
}
Expand Down
Loading