David Chin <prehensilecode@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date
Message
feat(spackenv): Adding Spackenv plugin (#13191)
* Add spackenv plugin to handle Spack environment
* Use ":t" instead of 'basename'
Diff
1diff --git a/plugins/spackenv/README.md b/plugins/spackenv/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..3715158394259bd4e8356df817be40dcfe9cd38c
4--- /dev/null
5+++ b/plugins/spackenv/README.md
6@@ -0,0 +1,17 @@
7+# spackenv
8+
9+Based on the virtualenv plugin.
10+
11+The plugin displays information of the created Spack environment and allows background theming.
12+
13+To use it, add `spackenv` to the plugins array of your zshrc file:
14+```
15+plugins=(... spackenv)
16+```
17+
18+The plugin creates a `spackenv_prompt_info` function that you can use in your theme, which displays
19+the basename of the current `$SPACK_ENV`. It uses two variables to control how that is shown:
20+
21+- `ZSH_THEME_SPACKENV_PREFIX`: sets the prefix of the SPACK_ENV. Defaults to `[`.
22+
23+- `ZSH_THEME_SPACKENV_SUFFIX`: sets the suffix of the SPACK_ENV. Defaults to `]`.
24diff --git a/plugins/spackenv/spackenv.plugin.zsh b/plugins/spackenv/spackenv.plugin.zsh
25new file mode 100644
26index 0000000000000000000000000000000000000000..f626f4fc694683e2b707742194271cfb5b9e8dc7
27--- /dev/null
28+++ b/plugins/spackenv/spackenv.plugin.zsh
29@@ -0,0 +1,5 @@
30+function spackenv_prompt_info(){
31+ [[ -n ${SPACK_ENV} ]] || return
32+ export SPACK_ENV_PROMPT=${SPACK_ENV:t}
33+ echo "${ZSH_THEME_SPACKENV_PREFIX=(}${SPACK_ENV:t:gs/%/%%}${ZSH_THEME_SPACKENV_SUFFIX=)}"
34+}