Files
dotfiles/scripts/.local/bin/direnv-create
2025-06-18 10:31:29 +01:00

28 lines
639 B
Bash

#!/usr/bin/env bash
if [ $# -gt 1 ]; then
echo "only supply the name of the shell you want to use"
exit 1;
fi
if [ $# -eq 1 ]; then
echo "use flake ~/.flake/shells#$1" > .envrc && direnv allow
else
echo "using local flake"
echo "use flake" > .envrc && direnv allow
fi
if [ -d "$PWD/.git" ]; then
echo "git dir detected..."
grep -q ".direnv" .git/info/exclude
if [ $? -ne 0 ]; then
echo "adding .direnv to exclude"
echo ".direnv" >> .git/info/exclude
fi
grep -q ".envrc" .git/info/exclude
if [ $? -ne 0 ]; then
echo "adding .envrc to exclude"
echo ".envrc" >> .git/info/exclude
fi
fi