For shello environments to be useful, their variables need to be exported into your terminal session. This can be achieved by adding the following to your .zshrc
, or .bash_profle
, or whatever file you use to source your shell.
## shello -- for managing environment variables
shello () {
## first clear the current environment's variables
currentPath="$HOME/Library/Containers/app.shello/Data/envs/$SHELLO_CURRENT_ENV"
if [ -f "$currentPath" ]; then
while IFS= read -r line || [[ -n "$line" ]]; do
key=$(echo "$line" | cut -d '=' -f1)
unset "$key"
done < "$currentPath"
fi
envFilePath="$HOME/Library/Containers/app.shello/Data/envs/$1"
# Check if the file exists
if [ -f "$envFilePath" ]; then
# Read each line from the file and set environment variables
while IFS= read -r line || [[ -n "$line" ]]; do
# Split line into KEY and VALUE
key=$(echo "$line" | cut -d '=' -f1)
value=$(echo "$line" | cut -d '=' -f2-)
# Set the environment variable
export "$key"="$value"
# echo "Setting $key from shello 🐚"
done < "$envFilePath"
export "SHELLO_CURRENT_ENV"="$1"
echo "🐚 shello env --> $1"
else
echo "File not found: $envFilePath"
fi
}
Optionally, you can load a default environment every time a terminal session is created.
shello {YOUR_DEFAULT_ENV_NAME}
Start a new terminal session and run the following command
shello {YOUR_ENV_NAME}