[bobthefish] More virtualenv tweaks

* Inline a one-line method that's called one place
 * Make sure __bobthecow_virtualenv_python_version doesn't fail if python isn't a symlink.
 * Add a visual segment indicator after python version glyph.
pull/2/head
Justin Hileman 10 years ago committed by Bruno Pinto
parent 8ac71fb43f
commit 623d162f2b

@ -310,25 +310,27 @@ function __bobthefish_prompt_dir -d 'Display a shortened form of the current dir
end
function __bobthefish_virtualenv_python_version -d 'Get current python version'
switch (readlink (which python))
set -l python_version (readlink (which python))
switch "$python_version"
case python2
echo $__bobthefish_superscript_glyph[2]
case python3
echo $__bobthefish_superscript_glyph[3]
case pypy
echo $__bobthefish_pypy_glyph
end
end
function __bobthefish_virtualenv -d 'Get the current virtualenv'
echo $__bobthefish_virtualenv_glyph(__bobthefish_virtualenv_python_version) (basename "$VIRTUAL_ENV")
end
end
function __bobthefish_prompt_virtualfish -d "Display activated virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself)"
set -q VIRTUAL_ENV; or return
set -l version_glyph (__bobthefish_virtualenv_python_version)
if test "$version_glyph"
__bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey
echo -n -s $__bobthefish_virtualenv_glyph $version_glyph
end
__bobthefish_start_segment $__bobthefish_med_blue $__bobthefish_lt_grey
set_color $__bobthefish_lt_grey --bold
echo -n -s (__bobthefish_virtualenv) ' '
echo -n -s (basename "$VIRTUAL_ENV") ' '
set_color normal
end

Loading…
Cancel
Save