forked from victoriadrake/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prototype solution for environment manager
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |