#env #environment #variable

env_perm

Sets environment variables in your profile

4 releases

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

#12 in #variable

Download history 23/week @ 2021-10-03 22/week @ 2021-10-10 21/week @ 2021-10-17 52/week @ 2021-10-24 28/week @ 2021-10-31 15/week @ 2021-11-07 2/week @ 2021-11-14 33/week @ 2021-11-21 53/week @ 2021-11-28 39/week @ 2021-12-05 51/week @ 2021-12-12 11/week @ 2021-12-19 3/week @ 2021-12-26 25/week @ 2022-01-02 57/week @ 2022-01-09 65/week @ 2022-01-16

150 downloads per month
Used in moltenvk_deps

MIT license

5KB
62 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

~110KB

e) ]