diff --git a/README.md b/README.md index 8d1f7d1..cd90f59 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,10 @@ secrets -- passwords, PII, etc. Assume everything else could be made public. If doc -- documentation of processes, ideas, memos, etc. llc -- corporate documents, financial ledger, business running venv -- python environment for this whole kiboodle + +To set up an environment that works with these scripts, start a shell +(preferably zsh, though bash should work) in this directory, and type: + +```sh +. bin/activate-all +``` diff --git a/bin/activate-all b/bin/activate-all new file mode 100755 index 0000000..ca3e971 --- /dev/null +++ b/bin/activate-all @@ -0,0 +1,36 @@ +#!/bin/echo "source me, don't run me" +### +# activate-all - shell environment for almanack +### +# Note, you should source these, not execute this script +# This stuff has been tried on zsh, but should work on bash. +### + +if [ -n "$BASH_VERSION" ]; then + script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +elif [ -n "$ZSH_VERSION" ]; then + script_dir=$(cd "$(dirname "$0")" && pwd) +else + echo "Unsupported shell." + exit 1 +fi +ALMANACK_ROOT=$(dirname $script_dir) + +# Check for the existence of the venv directory +if [ ! -d "$ALMANACK_ROOT/venv" ]; then + echo "The virtual environment directory does not exist. Please run:" + echo "python -m venv $ALMANACK_ROOT/venv --prompt almnck" + return 1 2>/dev/null || exit 1 +fi + +. $ALMANACK_ROOT/venv/bin/activate +PATH=$ALMANACK_ROOT/bin:$PATH + +# Default to going to the root of almanack +cd() { + if [[ $# -eq 0 ]]; then + builtin cd $ALMANACK_ROOT || builtin cd + else + builtin cd "$@" + fi +}