summaryrefslogtreecommitdiff
path: root/share/spack/setup-env.sh
diff options
context:
space:
mode:
authorHarmen Stoppels <me@harmenstoppels.nl>2023-11-06 07:53:26 +0100
committerGitHub <noreply@github.com>2023-11-05 22:53:26 -0800
commit3c641c85097cef24cbea238f2254ced90f57bd2c (patch)
tree44849b19551b4d1ff6cd6a8f0a0f9627c706e2ec /share/spack/setup-env.sh
parent141c7de5d89f32b203438e1d6fca1efd817299f7 (diff)
downloadspack-3c641c85097cef24cbea238f2254ced90f57bd2c.tar.gz
spack-3c641c85097cef24cbea238f2254ced90f57bd2c.tar.bz2
spack-3c641c85097cef24cbea238f2254ced90f57bd2c.tar.xz
spack-3c641c85097cef24cbea238f2254ced90f57bd2c.zip
spack env activate: create & activate default environment without args (#40756)
This PR implements the concept of "default environment", which doesn't have to be created explicitly. The aim is to lower the barrier for adopting environments. To (create and) activate the default environment, run ``` $ spack env activate ``` This mimics the behavior of ``` $ cd ``` which brings you to your home directory. This is not a breaking change, since `spack env activate` without arguments currently errors. It is similar to the already existing `spack env activate --temp` command which always creates an env in a temporary directory, the difference is that the default environment is a managed / named environment named `default`. The name `default` is not a reserved name, it's just that `spack env activate` creates it for you if you don't have it already. With this change, you can get started with environments faster: ``` $ spack env activate [--prompt] $ spack install --add x y z ``` instead of ``` $ spack env create default ==> Created environment 'default in /Users/harmenstoppels/spack/var/spack/environments/default ==> You can activate this environment with: ==> spack env activate default $ spack env activate [--prompt] default $ spack install --add x y z ``` Notice that Spack supports switching (but not stacking) environments, so the parallel with `cd` is pretty clear: ``` $ spack env activate named_env $ spack env status ==> In environment named_env $ spack env activate $ spack env status ==> In environment default ```
Diffstat (limited to 'share/spack/setup-env.sh')
-rwxr-xr-xshare/spack/setup-env.sh3
1 files changed, 1 insertions, 2 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 91a601e652..a42882266c 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -126,8 +126,7 @@ _spack_shell_wrapper() {
# Space needed here to differentiate between `-h`
# argument and environments with "-h" in the name.
# Also see: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion
- if [ -z ${1+x} ] || \
- [ "${_a#* --sh}" != "$_a" ] || \
+ if [ "${_a#* --sh}" != "$_a" ] || \
[ "${_a#* --csh}" != "$_a" ] || \
[ "${_a#* -h}" != "$_a" ] || \
[ "${_a#* --help}" != "$_a" ];