#env #environment #variable

set_env

Sets environment variables permanently across all major platforms

13 stable releases

Uses new Rust 2021

1.3.4 Jun 12, 2022
1.3.1 May 29, 2022
1.0.2 Apr 20, 2022

#2 in #environment-variable

Download history 5/week @ 2022-10-07 3/week @ 2022-10-14 20/week @ 2022-10-21 18/week @ 2022-10-28 17/week @ 2022-11-04 20/week @ 2022-11-11 19/week @ 2022-11-18 2/week @ 2022-11-25 5/week @ 2022-12-02 8/week @ 2022-12-09 10/week @ 2022-12-16 8/week @ 2022-12-23 31/week @ 2022-12-30 3/week @ 2023-01-06 1/week @ 2023-01-13 40/week @ 2023-01-20

77 downloads per month
Used in 2 crates

MIT license

11KB
173 lines

set_env

This crate allows you to permanently set environment variables

Based on env_perm

Examples

// Check if DUMMY is set, if not set it to 1
// export DUMMY=1
set_env::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"Cancel changes
set_env::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"
set_env::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.

On windows, this crate will modify the HKEY_CURRENT_USER\Environment registry items

Dependencies

~220KB