Bladeren bron

Add fish prompt changing (#475)

pull/478/head
Romir K 7 maanden geleden
committed by GitHub
bovenliggende
commit
0f83c33a3b
Geen bekende sleutel gevonden voor deze handtekening in de database GPG sleutel-ID: B5690EEEBB952194
6 gewijzigde bestanden met toevoegingen van 125 en 7 verwijderingen
  1. +14
    -1
      bin/pyenv-sh-activate
  2. +9
    -1
      bin/pyenv-sh-deactivate
  3. +48
    -4
      test/activate.bats
  4. +12
    -1
      test/conda-activate.bats
  5. +7
    -0
      test/conda-deactivate.bats
  6. +35
    -0
      test/deactivate.bats

+ 14
- 1
bin/pyenv-sh-activate Bestand weergeven

@ -245,7 +245,20 @@ if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
case "${shell}" in
fish )
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
;;
* )

+ 9
- 1
bin/pyenv-sh-deactivate Bestand weergeven

@ -187,7 +187,15 @@ esac
case "${shell}" in
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

+ 48
- 4
test/activate.bats Bestand weergeven

@ -138,7 +138,18 @@ EOS
deactivated
set -gx PYENV_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
unstub pyenv-version-name
@ -164,7 +175,18 @@ set -gx PYENV_VERSION "venv";
set -gx PYENV_ACTIVATE_SHELL 1;
set -gx PYENV_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
unstub pyenv-version-name
@ -239,7 +261,18 @@ set -gx PYENV_VERSION "venv27";
set -gx PYENV_ACTIVATE_SHELL 1;
set -gx PYENV_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
unstub pyenv-virtualenv-prefix
@ -263,7 +296,18 @@ set -gx PYENV_VERSION "venv27";
set -gx PYENV_ACTIVATE_SHELL 1;
set -gx PYENV_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
unstub pyenv-virtualenv-prefix

+ 12
- 1
test/conda-activate.bats Bestand weergeven

@ -70,7 +70,18 @@ deactivated
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 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
unstub pyenv-version-name

+ 7
- 0
test/conda-deactivate.bats Bestand weergeven

@ -82,6 +82,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;

+ 35
- 0
test/deactivate.bats Bestand weergeven

@ -225,6 +225,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;
@ -251,6 +258,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;
@ -279,6 +293,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;
@ -307,6 +328,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;
@ -333,6 +361,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
set -e _OLD_VIRTUAL_PYTHONHOME;
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;
functions -e deactivate;
end;

Laden…
Annuleren
Opslaan