mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Add fish prompt changing (#475)
This commit is contained in:
@@ -245,7 +245,20 @@ if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
|
|||||||
case "${shell}" in
|
case "${shell}" in
|
||||||
fish )
|
fish )
|
||||||
if [ -z "${QUIET}" ]; then
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
cat <<EOS
|
||||||
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(${venv}) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
|
EOS
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
|
|||||||
@@ -187,7 +187,15 @@ esac
|
|||||||
|
|
||||||
case "${shell}" in
|
case "${shell}" in
|
||||||
fish )
|
fish )
|
||||||
:
|
cat <<EOS
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
|
EOS
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
|
|||||||
@@ -138,7 +138,18 @@ EOS
|
|||||||
deactivated
|
deactivated
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
@@ -164,7 +175,18 @@ set -gx PYENV_VERSION "venv";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
@@ -239,7 +261,18 @@ set -gx PYENV_VERSION "venv27";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv27) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
@@ -263,7 +296,18 @@ set -gx PYENV_VERSION "venv27";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv27) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
|
|||||||
@@ -70,7 +70,18 @@ deactivated
|
|||||||
set -gx PYENV_VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
set -gx PYENV_VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
||||||
set -gx VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
set -gx VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
||||||
set -gx CONDA_DEFAULT_ENV "root";
|
set -gx CONDA_DEFAULT_ENV "root";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(anaconda-2.3.0) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -225,6 +225,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -251,6 +258,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -279,6 +293,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -307,6 +328,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -333,6 +361,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Reference in New Issue
Block a user