bin: Add to set up the basic working environment.

This commit is contained in:
Danny O'Brien 2023-12-12 21:37:33 -08:00
parent 555eb4f60b
commit 55589d995b
2 changed files with 43 additions and 0 deletions

View file

@ -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
```

36
bin/activate-all Executable file
View file

@ -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
}