summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chin <prehensilecode@users.noreply.github.com>2025-09-01 15:02:29 -0400
committerGitHub <noreply@github.com>2025-09-01 12:02:29 -0700
commit680298e920069b313650c1e1e413197c251c9cde (patch)
tree378a0120dcbeb290de8f81ac29b897ac54b050aa
parent61b144d809f8f8258cfd74a4bb3c6c8b66bac0b1 (diff)
downloadzsh-680298e920069b313650c1e1e413197c251c9cde.tar.gz
zsh-680298e920069b313650c1e1e413197c251c9cde.tar.bz2
zsh-680298e920069b313650c1e1e413197c251c9cde.zip
feat(spackenv): Adding Spackenv plugin (#13191)
* Add spackenv plugin to handle Spack environment * Use ":t" instead of 'basename'
-rw-r--r--plugins/spackenv/README.md17
-rw-r--r--plugins/spackenv/spackenv.plugin.zsh5
2 files changed, 22 insertions, 0 deletions
diff --git a/plugins/spackenv/README.md b/plugins/spackenv/README.md
new file mode 100644
index 000000000..371515839
--- /dev/null
+++ b/plugins/spackenv/README.md
@@ -0,0 +1,17 @@
+# spackenv
+
+Based on the virtualenv plugin.
+
+The plugin displays information of the created Spack environment and allows background theming.
+
+To use it, add `spackenv` to the plugins array of your zshrc file:
+```
+plugins=(... spackenv)
+```
+
+The plugin creates a `spackenv_prompt_info` function that you can use in your theme, which displays
+the basename of the current `$SPACK_ENV`. It uses two variables to control how that is shown:
+
+- `ZSH_THEME_SPACKENV_PREFIX`: sets the prefix of the SPACK_ENV. Defaults to `[`.
+
+- `ZSH_THEME_SPACKENV_SUFFIX`: sets the suffix of the SPACK_ENV. Defaults to `]`.
diff --git a/plugins/spackenv/spackenv.plugin.zsh b/plugins/spackenv/spackenv.plugin.zsh
new file mode 100644
index 000000000..f626f4fc6
--- /dev/null
+++ b/plugins/spackenv/spackenv.plugin.zsh
@@ -0,0 +1,5 @@
+function spackenv_prompt_info(){
+ [[ -n ${SPACK_ENV} ]] || return
+ export SPACK_ENV_PROMPT=${SPACK_ENV:t}
+ echo "${ZSH_THEME_SPACKENV_PREFIX=(}${SPACK_ENV:t:gs/%/%%}${ZSH_THEME_SPACKENV_SUFFIX=)}"
+}