https://github.com/egor-tensin/windows-env
Manage Windows environment variables
https://github.com/egor-tensin/windows-env
Last synced: 8 months ago
JSON representation
Manage Windows environment variables
- Host: GitHub
- URL: https://github.com/egor-tensin/windows-env
- Owner: egor-tensin
- License: mit
- Created: 2015-05-06T03:26:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-28T19:37:40.000Z (over 1 year ago)
- Last Synced: 2025-01-11T21:23:30.532Z (9 months ago)
- Language: Haskell
- Homepage:
- Size: 131 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Windows environment variables
=============================[](https://github.com/egor-tensin/windows-env/actions/workflows/ci.yml)
A collection of simple utilities to manage Windows environment variables,
created mainly to:* learn a bit of Haskell,
* make it easier to add directories to the `PATH` variable, list missing
directories in your `PATH`, etc.Building
--------Using [stack]:
```
> stack setup
...> stack build
...
```[stack]: http://docs.haskellstack.org/en/stable/README/
To prepare for making a release the following commands might be useful:
```
> stack build --install-ghc --copy-bins --local-bin-path ..\windows-env-x86 --arch i386
...> stack build --install-ghc --copy-bins --local-bin-path ..\windows-env-x64 --arch x86_64
...
```Installation
------------```
> stack install
...
```Usage
-----The complete list of utilities is given below.
* [paths] — List directories in your `PATH`.
* [addpath] — Add directories to `PATH`.
* [delpath] — Remove directories from `PATH`.
* [setenv] — Assign values to environment variables.
* [delenv] — Delete environment variables.Pass the `--help` flag to an utility to examine its detailed usage information.
Some examples are given below.[paths]: #paths
[addpath]: #addpath
[delpath]: #delpath
[setenv]: #setenv
[delenv]: #delenv### paths
List directories in your `PATH`:
```
> paths
C:\Program Files\Haskell\bin
C:\Program Files\Haskell Platform\8.0.1\lib\extralibs\bin
C:\Program Files\Haskell Platform\8.0.1\bin
C:\Users\Egor\AppData\Roaming\local\bin
C:\Users\Egor\AppData\Roaming\cabal\bin
...
```Only list missing directories in your `PATH`:
```
> paths --missing
C:\Users\Egor\AppData\Roaming\cabal\bin
...
```### addpath
Add "C:\test" to current user's `PATH`:
```
> addpath C:\test
Saving variable 'PATH' to 'HKCU\Environment'...
Old value: C:\Users\Egor\AppData\Roaming\local\bin;C:\Users\Egor\AppData\Roaming\cabal\bin
New value: C:\Users\Egor\AppData\Roaming\local\bin;C:\Users\Egor\AppData\Roaming\cabal\bin;C:\test
Continue? (y/n) y
```Add "C:\test" to the global `PATH`, skipping the confirmation prompt:
```
> addpath --global -y C:\test
```### delpath
Remove "C:\test" from current user's `PATH`:
```
> delpath C:\test
Saving variable 'PATH' to 'HKCU\Environment'...
Old value: C:\Users\Egor\AppData\Roaming\local\bin;C:\Users\Egor\AppData\Roaming\cabal\bin;C:\test
New value: C:\Users\Egor\AppData\Roaming\local\bin;C:\Users\Egor\AppData\Roaming\cabal\bin
```Remove "C:\test" from both current user's and the global `PATH`s, skipping the
confirmation prompt:```
> delpath --global -y C:\test
```### setenv
Assign `bar` to the variable `foo` in current user's environment, skipping the
confirmation prompt:```
> setenv -y foo bar
```Assign `bar` to the variable `foo` in the global environment:
```
> setenv --global foo bar
Saving variable 'foo' to 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'...
New value: bar
Continue? (y/n) y
```### delenv
Delete the variable `foo` from current users's environment, skipping the
confirmation prompt:```
> delenv -y foo
```Delete the variable `foo` from the global environment:
```
> delenv --global foo
Deleting variable 'foo' from 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'...
Continue? (y/n) y
```License
-------Distributed under the MIT License.
See [LICENSE.txt] for details.[LICENSE.txt]: LICENSE.txt