https://github.com/jrhawley/pad-path
Intuitively modify your `$PATH`
https://github.com/jrhawley/pad-path
cli command-line-tool environment-variables path
Last synced: 11 months ago
JSON representation
Intuitively modify your `$PATH`
- Host: GitHub
- URL: https://github.com/jrhawley/pad-path
- Owner: jrhawley
- License: mit
- Created: 2020-11-14T19:15:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T21:43:27.000Z (over 2 years ago)
- Last Synced: 2025-06-06T16:05:29.611Z (about 1 year ago)
- Topics: cli, command-line-tool, environment-variables, path
- Language: Rust
- Homepage: https://jrhawley.ca/2020/11/16/pad-path
- Size: 441 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# pad-path
Intuitively modify your `$PATH`.

## Installation
### Windows (via Scoop)
```shell
# add the bucket containing pad-path's manifest
scoop bucket add jrhawley https://gitlab.com/jrhawley/scoop-bucket
# install
scoop install pad-path
```
### Nix
```shell
nix profile install gitlab:jrhawley/pad-path
```
### Build from source (via Cargo)
```shell
# directly from crates.io
cargo install pad-path
# or, equivalently, after downloading the code repo
git clone https://gitlab.com/jrhawley/pad-path
cd pad-path
cargo install --path .
```
## Usage
```shell
Intuitively modify your `$PATH`
USAGE:
pad [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
add Add a directory
clean Remove duplicates and non-existent directories [aliases: dedup]
dn Decrease priority for a directory [aliases: down, dec]
help Prints this message or the help of the given subcommand(s)
ls List the directories in PATH [aliases: echo]
revert Revert to a previous version of PATH [aliases: undo]
rm Remove a directory [aliases: del]
up Increase priority for a directory [aliases: inc]
```
It would be convenient, but insecure, to have `pad-path` modify the shell's environment variables directly.
Instead, `pad-path` prints out what the new `$PATH` will look like, and the user can set it as the value for `$PATH`, or pipe it to another command.
### Examples
In Bash, an example workflow is below.
```bash
# display your current $PATH
> pad ls
/folder/to/remove
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
# preview what $PATH would look like if you remove the first folder
> pad rm /folder/to/remove
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
# set the new $PATH
> export PATH=$(pad rm /folder/to/remove)
# see that the new path is set
> echo $PATH
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
```
Similarly, in PowerShell, you can assign the output of a `pad-path` command to `$Env:Path`.
```powershell
# check the value of $Env:Path
> pad ls
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\WINDOWS\System32\OpenSSH
C:\Program Files\dotnet
# add a new variable to $Env:Path
> $Env:Path = (pad add "C:\Program Files\new_dir")
# check that the folder has been added correctly
> pad ls
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\WINDOWS\System32\OpenSSH
C:\Program Files\dotnet
C:\Program Files\new_dir
```