From 343b4dde32ae6fd5d225237909283b5c5dc022d4 Mon Sep 17 00:00:00 2001 From: Wilson Biggs Date: Tue, 20 Jun 2023 11:54:42 -0400 Subject: [PATCH 1/4] Make displaying python version configurable --- functions/fish_prompt.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 1ec90fd..788585d 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -33,6 +33,7 @@ # set -g theme_display_aws_vault_profile yes # set -g theme_display_hg yes # set -g theme_display_virtualenv no +# set -g theme_display_virtualenv_python_version no # set -g theme_display_nix no # set -g theme_display_ruby no # set -g theme_display_user ssh @@ -849,6 +850,9 @@ function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' end function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' + [ "$theme_display_virtualenv_python_version" = 'no' ] + and return + switch (python --version 2>&1 | tr '\n' ' ') case 'Python 2*PyPy*' echo $pypy_glyph From c14fc0f92d79ba6f01464767421a2e6b98bb47d3 Mon Sep 17 00:00:00 2001 From: Wilson Biggs Date: Tue, 20 Jun 2023 12:05:11 -0400 Subject: [PATCH 2/4] Only hide version, don't remove glyph and color, and preserve behavior for unmatched python --- functions/fish_prompt.fish | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index 788585d..ede23e2 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -873,7 +873,11 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e if [ "$version_glyph" ] __bobthefish_start_segment $color_virtualfish - echo -ns $virtualenv_glyph $version_glyph ' ' + echo -ns $virtualenv_glyph + if [ "$theme_display_virtualenv_python_version" != 'no' ] + echo -ns $version_glyph + end + echo -ns ' ' end if [ "$VIRTUAL_ENV" ] From 88671c1d42198b80399a8147b77b1d4f006fb2a9 Mon Sep 17 00:00:00 2001 From: Wilson Biggs Date: Tue, 20 Jun 2023 12:07:11 -0400 Subject: [PATCH 3/4] Fix condition for if python version hidden --- functions/fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index ede23e2..fd6d9e8 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -871,7 +871,7 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e set -l version_glyph (__bobthefish_virtualenv_python_version) - if [ "$version_glyph" ] + if [ "$version_glyph" -o "$theme_display_virtualenv_python_version" = 'no' ] __bobthefish_start_segment $color_virtualfish echo -ns $virtualenv_glyph if [ "$theme_display_virtualenv_python_version" != 'no' ] From dcec53f35c8131914de87d533a262291993c1124 Mon Sep 17 00:00:00 2001 From: Wilson Biggs Date: Tue, 20 Jun 2023 12:16:27 -0400 Subject: [PATCH 4/4] Simplify logic? --- functions/fish_prompt.fish | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish index fd6d9e8..28761d1 100644 --- a/functions/fish_prompt.fish +++ b/functions/fish_prompt.fish @@ -873,11 +873,7 @@ function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual e if [ "$version_glyph" -o "$theme_display_virtualenv_python_version" = 'no' ] __bobthefish_start_segment $color_virtualfish - echo -ns $virtualenv_glyph - if [ "$theme_display_virtualenv_python_version" != 'no' ] - echo -ns $version_glyph - end - echo -ns ' ' + echo -ns $virtualenv_glyph $version_glyph ' ' end if [ "$VIRTUAL_ENV" ]