Skip to content

berk-karaal/loadenv.fish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

loadenv.fish

Tests workflow

loadenv is a Fish shell function for managing environment variables from dotenv files.

Usage: loadenv [OPTIONS] [FILE]

Export keys and values from a dotenv file.

Options:
  --help, -h      Show this help message
  --print         Print env keys (export preview)
  --printb        Print keys with surrounding brackets
  --unload, -U    Unexport all keys defined in the dotenv file

Arguments:
  FILE            Path to dotenv file (default: .env)

Check tests/happy.env for a sample dotenv file.

Installation

Using Fisher (Plugin manager for Fish):

$ fisher install berk-karaal/loadenv.fish

or manually copy the functions/loadenv.fish file to your Fish functions directory (e.g. ~/.config/fish/functions/).

Usage

Load .env file:

$ loadenv

Load custom file:

$ loadenv path/to/dotenv.env

Preview variables defined in the dotenv file:

$ loadenv --print
$ # or
$ loadenv --printb

Unexport all keys defined in the dotenv file:

$ loadenv --unload

Example dotenv file

# Sample dotenv file (.env.example)

# This is a comment
KEY1=value1

QUOTED_KEY="This is a quoted value" # inline comment
SINGLE_QUOTED_KEY='Single quoted value'

# Support for multi-line values
MULTI_LINE_KEY="""This is a multi-line
value that spans several lines.

1
2
3"""
$ loadenv .env.example --printb
[KEY1=value1]
[QUOTED_KEY=This is a quoted value]
[SINGLE_QUOTED_KEY=Single quoted value]
[MULTI_LINE_KEY=This is a multi-line
value that spans several lines.

1
2
3]

About

Fish shell function for managing env vars from dotenv files ๐ŸŸ

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •