Skip to content

Commit

Permalink
Add prototype solution for environment manager
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jun 23, 2023
1 parent 5379566 commit 27983ef
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/profile/loadenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Maintains a global register of direnv locations.
# Starts a Bash session that uses the environment in any working directory.
# Inspired by direnv and bashmarks.

if [ ! -n "$ENVDIR" ]; then
ENVDIR="${HOME}/.config/envsets"
fi
mkdir --parents "$ENVDIR"

function .env {
declare name="${1}"

bash --init-file <(cat \
~/.bashrc \
<(direnv stdlib) \
"$ENVDIR/$name" \
<(cat <<< "export PS1='($name) $PS1'") \
)
}

function lnenv {
declare name="${1}"

ln -s -i -T "$(pwd)/.envrc" "$ENVDIR/$name"
}

function rmenv {
declare name="${1}"

rm "$ENVDIR/$name"
}

function lsenv {
find "$ENVDIR" -mindepth 1 -maxdepth 1 -printf "%f -> %l\n"
}

0 comments on commit 27983ef

Please sign in to comment.