4 releases

✓ Uses Rust 2018 edition

0.1.3 Jun 20, 2019
0.1.2 Jun 20, 2019
0.1.1 Jan 1, 2019
0.1.0 Dec 21, 2018

#45 in Configuration

Download history 41/week @ 2019-12-02 79/week @ 2019-12-09 19/week @ 2019-12-16 23/week @ 2019-12-23 20/week @ 2019-12-30 19/week @ 2020-01-06 60/week @ 2020-01-13 27/week @ 2020-01-20 18/week @ 2020-01-27 22/week @ 2020-02-03 28/week @ 2020-02-10 33/week @ 2020-02-17 38/week @ 2020-02-24 30/week @ 2020-03-02 16/week @ 2020-03-09 11/week @ 2020-03-16

214 downloads per month
Used in 2 crates (via moltenvk_deps)

MIT license

5KB
53 lines

env_perm

This crate allows you to permanently set environment variables

Examples

// Check if DUMMY is set, if not set it to 1
// export DUMMY=1
env_perm::check_or_set("DUMMY", 1).expect("Failed to find or set DUMMY");
// Append $HOME/some/cool/bin to $PATH
// export PATH= "$HOME/some/cool/bin:$PATH"
env_perm::append("PATH", "$HOME/some/cool/bin").expect("Couldn't find PATH");
// Sets a variable without checking if it exists.
// Note you need to use a raw string literal to include ""
// export DUMMY="/something"
env_perm::set("DUMMY", r#""/something""#).expect("Failed to set DUMMY");

Usage

This crate simply appends to your .bash_profile or .bash_login or .profile in that order. It will create a .bash_profile file if none of the above are found in your home directory. ie. /Users/me/.bash_profile.

I have only tested this on macOS but it should work on any unix system. I want to add windows support soon.

Contributions are welcome.


lib.rs:

This crate allows you to permanently set environment variables

Examples

// Check if DUMMY is set, if not set it to 1
// export DUMMY=1
env_perm::check_or_set("DUMMY", 1).expect("Failed to find or set DUMMY");
// Append $HOME/some/cool/bin to $PATH
// export PATH= "$HOME/some/cool/bin:$PATH"
env_perm::append("PATH", "$HOME/some/cool/bin").expect("Couldn't find PATH");
// Sets a variable without checking if it exists.
// Note you need to use a raw string literal to include ""
// export DUMMY="/something"
env_perm::set("DUMMY", r#""/something""#).expect("Failed to set DUMMY");

Dependencies

~175KB