From 0ce4c4ceea7ddd24dc5452aa0df5be63cf6c5907 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 30 Nov 2022 17:47:56 +0200 Subject: [PATCH] Supporting zsh * Parameter substitution is done differently for zsh * Using @ modifier to split strings - Added environment variable 'GENV_SHELL' (based on $SHELL) - Added helper function '_genv_get_env' --- docs/source/development/development.rst | 2 +- docs/source/development/reference.rst | 7 +++++++ libexec/genv | 1 + libexec/genv-sh-activate | 26 ++++++++++++++++++------- libexec/genv-sh-deactivate | 15 ++++++++++++-- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/docs/source/development/development.rst b/docs/source/development/development.rst index 1c3052c..b74e023 100644 --- a/docs/source/development/development.rst +++ b/docs/source/development/development.rst @@ -19,7 +19,7 @@ Open a terminal in the project directory. .. warning:: - We support :code:`bash` terminals only at the moment. Query your shell using :code:`echo $SHELL` and run :code:`bash` if it is not your shell, or use a :ref:`Docker ` setup instead. + We support :code:`bash` and :code:`zsh` terminals only at the moment. Query your shell using :code:`echo $SHELL` and run :code:`bash` if your shell is not supported, or use a :ref:`Docker ` setup instead. Then run the following commands to configure your terminal: diff --git a/docs/source/development/reference.rst b/docs/source/development/reference.rst index ed1c581..ae4f38e 100644 --- a/docs/source/development/reference.rst +++ b/docs/source/development/reference.rst @@ -30,6 +30,13 @@ This is mainly for development environments on CPU machines where :code:`nvidia- ---- +:code:`GENV_SHELL` + +Set the shell type (e.g. `zsh`, `bash`). +Default is based on environment variable :code:`$SHELL`. + +---- + :code:`GENV_TMPDIR` Path of the temp directory where all state JSON files are stored. diff --git a/libexec/genv b/libexec/genv index cc639b1..2ff2d71 100755 --- a/libexec/genv +++ b/libexec/genv @@ -4,6 +4,7 @@ set -e [ -n "$GENV_DEBUG" ] && set -x export GENV_ROOT=${GENV_ROOT:-"$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/.."} +export GENV_SHELL=${GENV_SHELL:-${SHELL##*/}} # TODO(raz): we should check the actual running shell and not the default one export PATH="$GENV_ROOT/libexec:$PATH" export PYTHONPATH="$GENV_ROOT/py:$PYTHONPATH" diff --git a/libexec/genv-sh-activate b/libexec/genv-sh-activate index 0b84fa7..81bb35d 100755 --- a/libexec/genv-sh-activate +++ b/libexec/genv-sh-activate @@ -126,10 +126,20 @@ done function functions() { cat <