[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.
This commit is contained in:
Justin Hileman 2014-11-22 01:47:04 -08:00 committed by Bruno Pinto
parent f6456dbc26
commit a4ba3bc8e7

View File

@ -310,7 +310,8 @@ 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
@ -320,15 +321,16 @@ function __bobthefish_virtualenv_python_version -d 'Get current python version'
end
end
function __bobthefish_virtualenv -d 'Get the current virtualenv'
echo $__bobthefish_virtualenv_glyph(__bobthefish_virtualenv_python_version) (basename "$VIRTUAL_ENV")
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