Skip to content

bep/firstupdotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a simple Go program that finds the first firstup.env file starting from the current directory walking upwareds, excluding the root folder.

It will write the env vars as export statements. It will also store the list of keys set in a separate environment variable and unset those next time firstupdotenv is run.

The output may then look like this:

unset FOO
unset BAR
export FIRSTUPDOTENV_CURRENT_SET_ENV=FOO,BAR
export FOO=value1
export BAR=value2

The .env format is a file on the form key=value. It ignores empty lines and lines starting with # and lines without an equals sign. If the same key is defined more than once, the last will win.

To install:

go install github.com/bep/firstupdotenv@latest

This tool is meant to be used in combination with some shell extension that triggers when you cd into a directory. If you use the Z shell, putting this in your .zshrc will work:

autoload -U add-zsh-hook

firstupdotenv_after_cd() {
	source <(firstupdotenv)
}

add-zsh-hook chpwd firstupdotenv_after_cd

About

Loads env from the first firstup.env it finds.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages