Make virtual_env item smarter (closes #97)

This commit is contained in:
Ilan Cosman 2021-02-28 15:37:19 -08:00
parent 4f621eae3f
commit aa50156af9
2 changed files with 11 additions and 17 deletions

View File

@ -1,11 +1,11 @@
function _tide_item_virtual_env
if set -l splitVirtualEnv (string split '/' "$VIRTUAL_ENV")
set_color $tide_virtual_env_color
if test "$tide_virtual_env_display_mode" = 'venvName'
printf '%s' $tide_virtual_env_icon' ' $splitVirtualEnv[-1]
else # Default to projectName
# Avoid printing a generic name
if contains -- $splitVirtualEnv[-1] virtualenv venv .venv env
printf '%s' $tide_virtual_env_icon' ' $splitVirtualEnv[-2]
else
printf '%s' $tide_virtual_env_icon' ' $splitVirtualEnv[-1]
end
end
end

View File

@ -4,19 +4,13 @@ function _virtual_env
_tide_decolor (_tide_item_virtual_env)
end
set -lx VIRTUAL_ENV
_virtual_env # CHECK:
set -lx VIRTUAL_ENV ~/python_project/.venv
set -lx tide_virtual_env_icon ''
set -lx tide_virtual_env_display_mode projectName
set -lx VIRTUAL_ENV
_virtual_env # CHECK:
set -lx VIRTUAL_ENV ~/python_project/non-generic-name
_virtual_env # CHECK:  non-generic-name
set -lx VIRTUAL_ENV ~/python_project/venv
_virtual_env # CHECK:  python_project
set -lx tide_virtual_env_display_mode venvName
_virtual_env # CHECK:  .venv
set -lx tide_virtual_env_icon
set -lx tide_virtual_env_display_mode projectName
_virtual_env # CHECK: python_project