Skip to content

jeremfg/config.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

config.sh

Manage .env configuration files for Shell

Install

bpkg install jeremfg/config.sh

or

bpkg install -g jeremfg/config.sh

NOTE: bpkg itself can easily be installed by calling curl -sLo- https://get.bpkg.sh | bash

In the first case, the library is installed local to your project. You will need to source deps/config.sh/src/config.sh. In the second case, the library is installed globally. You will need to source ~/.local/lib/config.sh.

Features

Provides the following functions:

config_load()
config_save()

Usage example:

# Assuming a BPKG global installation
source ${HOME}/.local/lib/config.sh

config_load "~/my_cool_config.env"
config_save "~/my_cool_config.env" "KEY_TO_SAVE" "VALUE_TO_SAVE"

SOPS encryption

When calling config_save, an existing key will be updated with the new value if it exists or a new entry will be created to store the value. If passing an empty value, the key will be deleted from the file.

The <file> can be encrypted upon calling config_load. Likewise, if the existing file is encrypted upon calling config_save, the changes will be encrypted back during save to disk, letting SOPS use environment variables to determine how the file should be encrypted.

Special values

config.sh supports special values and will perform replacement upon config_load if these strings are detected

Special Value Description
@GIT_ROOT@ Path to the parent repository root (equivalent to git rev-parse --show-superproject-working-tree). This is relative to the CWD.

These special values are mostly useful to create project-relative configuraitons

Setup for developers

Once you've checked out this repository call the following:

./tool/setup

Release

To create a release, call

./tool_release <version>

Where <version> is a semantic version 2.0.0 version number

About

Manage configuration files for Shell

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages