Created
May 26, 2013 21:50
-
-
Save idan/5654123 to your computer and use it in GitHub Desktop.
autoenv.fish and example .env.fish file
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
set -x DJANGO_SECRET_KEY "foo_123123123" | |
set -x AWS_ACCESS_KEY_ID "bar_456456456" |
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
if not set -q AUTOENVFISH_FILE | |
set -g AUTOENVFISH_FILE ".env.fish" | |
end | |
# Automatic env | |
function __vfsupport_autoenv --on-variable PWD | |
if status --is-command-substitution # doesn't work with 'or', inexplicably | |
return | |
end | |
# find an autoenv file, checking up the directory tree until we find | |
# such a file (or nothing) | |
set -l envfishdir $PWD | |
while test ! "$envfishdir" = "" -a ! -f "$envfishdir/$AUTOENVFISH_FILE" | |
# this strips the last path component from the path. | |
set envfishdir (echo "$envfishdir" | sed 's|/[^/]*$||') | |
end | |
if [ -f "$envfishdir/$AUTOENVFISH_FILE" ] | |
. "$envfishdir/$AUTOENVFISH_FILE" | |
end | |
end | |
#automatically activate if started in a directory with an .env.fish in it | |
__vfsupport_autoenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment