Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activate for bash/zsh #848

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions hack/activate/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file must be used with "source hack/activate/bash" *from bash*. You
# cannot run it directly

deactivate () {
# Reset old environment variables.
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi

# This should detect bash and zsh, which have a hash command that must be
# called to get it to forget past commands. Without forgetting past commands
# the $PATH changes we made may not be respected.
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# Unset irrelevant variables.
deactivate nondestructive

export VIRTUAL_ENV="$HOME/.cache/enduro-sdps/Linux/$(uname -m)/bin"

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV:$PATH"
export PATH

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(.venv) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(.venv) "
export VIRTUAL_ENV_PROMPT
fi

# This should detect bash and zsh, which have a hash command that must be called
# to get it to forget past commands. Without forgetting past commands the $PATH
# changes we made may not be respected.
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
5 changes: 3 additions & 2 deletions hack/activate.fish → hack/activate/fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file must be used with "source hack/activate.fish" *from fish*
# This file must be used with "source hack/activate/fish" *from fish*
# (https://fishshell.com/docs/current/cmds/source.html). You cannot run it
# directly.

Expand Down Expand Up @@ -29,7 +29,8 @@ end
# Unset irrelevant variables.
deactivate nondestructive

set -gx VIRTUAL_ENV "$HOME/.cache/enduro-sdps/Linux/x86_64/bin"
set -l arch (uname -m)
set -gx VIRTUAL_ENV "$HOME/.cache/enduro-sdps/Linux/$arch/bin"

set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV" $PATH
Expand Down
Loading