]> arthur.barton.de Git - ax-zsh.git/commitdiff
New "venv" plugin
authorAlexander Barton <alex@barton.de>
Tue, 28 Aug 2018 07:55:45 +0000 (09:55 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 12 Sep 2018 14:14:26 +0000 (16:14 +0200)
This can be used to activate Python "virtual venv environments", but
is basically language agnostic.

plugins/venv/README.md [new file with mode: 0644]
plugins/venv/venv.zshrc [new file with mode: 0644]

diff --git a/plugins/venv/README.md b/plugins/venv/README.md
new file mode 100644 (file)
index 0000000..9addab9
--- /dev/null
@@ -0,0 +1,9 @@
+## venv
+
+Add support for Python "venv" virtual environments.
+
+### Command Aliases
+
+- `activate`: try to activate a Python "venv" in the current directory. Both the
+  path names `./bin/activate` as well as `./venv/bin/activate` are tried, and
+  the script found will be sourced (not executed).
diff --git a/plugins/venv/venv.zshrc b/plugins/venv/venv.zshrc
new file mode 100644 (file)
index 0000000..9fcadbf
--- /dev/null
@@ -0,0 +1,16 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# venv.zshrc: Support Python "venv" virtual environments
+
+[[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92
+
+function activate() {
+       for p (.venv/bin bin); do
+               activate="$PWD/$p/activate"
+               if [[ -r "$activate" ]]; then
+                       source "$activate"
+                       return 0
+               fi
+       done
+       echo "No virtual environment found in \"$PWD\"!"
+       return 1
+}