From ee5c1e29b8fac6369ee56e53e1e8dd0a99062c86 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 18 Oct 2016 07:25:22 -0700 Subject: [PATCH] More efficient python version checking, capture pypy3. --- fish_prompt.fish | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index c66d3c5..9f06d7f 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -538,12 +538,16 @@ function __bobthefish_prompt_vi -S -d 'Display vi mode' end function __bobthefish_virtualenv_python_version -S -d 'Get current python version' - set -l python_version_out (python --version 2>&1) - set -l python_version (echo $python_version_out | grep --only-matching 'Python .' | grep --only-matching '.$') - if echo $python_version_out | grep -q 'PyPy' - echo $__bobthefish_pypy_glyph + switch (python --version ^&1) + case 'Python 2*PyPy*' + echo $__bobthefish_pypy_glyph + case 'Python 3*PyPy*' + echo -s $__bobthefish_pypy_glyph $__bobthefish_superscript_glyph[3] + case 'Python 2*' + echo $__bobthefish_superscript_glyph[2] + case 'Python 3*' + echo $__bobthefish_superscript_glyph[3] end - echo $__bobthefish_superscript_glyph[$python_version] end function __bobthefish_prompt_virtualfish -S -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"