Cross platform(ish) productivity commands written in python.
Project description
setenvironment
Finally, a cross platform way to set system environment variables and paths that are persistant across reboots.
Works with Windows, MacOS and Linux and github runners, see note below.
Extensively tested.
Command line interface
# Setting environmental variables
setenvironment show
setenviornment bashrc # unix only.
setenvironment set foo bar
setenvironment has foo
setenvironment get foo
setenvironment del foo
# Path manipulation.
setenvironment addpath /my/path
setenvironment get PATH
setenvironment delpath /my/path
setenvironment refresh "echo this command is in a refreshed environment"
Python API
from setenvironment import (
set_env_var, add_env_path, unset_env_var, remove_env_path, set_config_file, reload_environment, ...
)
# by default, ~/.bashrc is used
set_env_var("FOO", "BAR")
get_env_var("FOO") # returns BAR
add_env_path("MYPATH")
unset_env_var("FOO")
remove_env_path("MYPATH")
# use ~/.bash_profile instead (no op on Windows)
set_config_file("~/.bash_profile")
set_env_var("FOO", "BAR")
add_env_path("MYPATH")
unset_env_var("FOO")
remove_env_path("MYPATH")
# Loads settings into the current environment. This reads the
# registry on windows or the ~/.bashrc file on unix.
reload_environment()
# Path groups are usefull for uninstall programs. Each add
# copies the path both into the PATH and also to the key.
# When you want to remove paths you can query the key and selectively
# remove paths that are in the set.
add_to_path_group("MYPATHKEY", "/path/to/dir")
remove_to_path_group("MYPATHKEY", "/path/to/dir")
# Or else you can just remove ALL of the paths at once.
remove_path_group("MYPATHKEY")
Github
These are designed to be compatible with github runners.
Ubuntu MUST use the following to make this package work.
name: Ubuntu_Tests
# Directs GitHub to run tests using ~/.bashrc
defaults:
run:
shell: bash -ieo pipefail {0}
on: [push]
Windows
Paths are set in the registery and the current os.environ
- writes to the registery
- broadcasts the new value (cmd.exe ignores this though) to all available processes
- paths like
/my/path
will be converted to\\my\\path
MacOS / Linux
Paths are set in either ~/.bash_aliases
or ~/.bash_profile
or ~/.bashrc
file or you can override it, see set_config_file(...)
and the command line arguments if using the command line api.
- export the variable (so you can source the script)
- set the os.environ to the proper value
- write the value to the .bashrc file (make sure it's chmod +w)
Release Notes
- 2.0.3: Disables the refresh.cmd, since it doesn't work for subprocesses.
- 2.0.2: Re-enabled broadcast changes on win32, fixing new terminal launch.
- 2.0.1: Bug fix.
- 2.0.0: Rewrite. New command line api. Extensively tested on mac/win/ubuntu X github.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file setenvironment-2.0.3.tar.gz
.
File metadata
- Download URL: setenvironment-2.0.3.tar.gz
- Upload date:
- Size: 29.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d79b41981df0c7349396aaaea99c18e282795e4c20e3c5ad060003a61d7629b |
|
MD5 | 4c431fbe54df3deacd7256766d22b5d5 |
|
BLAKE2b-256 | 1b747cdc8d78e06e32955f14c0ac6b4905bf1375d60968a61144b8b358ae3760 |
File details
Details for the file setenvironment-2.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: setenvironment-2.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cee2abdf2b8a479a01f1e02dab8d03eaf99c449a1d47093517ae17992e568e4 |
|
MD5 | 540cd3ff3417b8c75ac765eb61b743c8 |
|
BLAKE2b-256 | bd33e023fa75cdf7965700a76e694358d75a20a83e91d9458f58891dff94bd73 |