Skip to content

Instantly share code, notes, and snippets.

@idan
Created May 26, 2013 21:50
Show Gist options
  • Save idan/5654123 to your computer and use it in GitHub Desktop.
Save idan/5654123 to your computer and use it in GitHub Desktop.
autoenv.fish and example .env.fish file
set -x DJANGO_SECRET_KEY "foo_123123123"
set -x AWS_ACCESS_KEY_ID "bar_456456456"
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