49 lines
1.3 KiB
Text
Executable file
49 lines
1.3 KiB
Text
Executable file
#!/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.
|
|
# There are other commands that use zsh, though, so you should
|
|
# probably install it.
|
|
###
|
|
|
|
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
|
|
|
|
declare -x 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
|
|
}
|
|
|
|
# Almanack utilities
|
|
|
|
a-pass() {
|
|
PASSWORD_STORE_DIR=$ALMANACK_ROOT/secrets/ env pass $*
|
|
}
|
|
|
|
pass() {
|
|
echo "You probably mean a-pass. If you mean pass, type env pass (This is to stop password stores getting mixed up)"
|
|
}
|