almnck/bin/a-activate

50 lines
1.3 KiB
Text
Raw Normal View History

#!/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.
2024-01-05 22:00:08 -08:00
# 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
2025-07-08 21:02:38 -07:00
if [ ! -d "$ALMANACK_ROOT/.venv" ]; then
echo "The virtual environment directory does not exist. Please run:"
2025-07-08 21:02:38 -07:00
echo "python -m venv $ALMANACK_ROOT/.venv --prompt almnck"
return 1 2>/dev/null || exit 1
fi
2025-07-08 21:02:38 -07:00
. $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() {
2024-01-04 23:40:39 -08:00
PASSWORD_STORE_DIR=$ALMANACK_ROOT/secrets/ env pass $*
2023-12-13 00:48:09 -08:00
}
2024-01-04 23:40:39 -08:00
pass() {
echo "You probably mean a-pass. If you mean pass, type env pass (This is to stop password stores getting mixed up)"
}