/path

Command-line tool to manage PATH environment variable

Primary LanguageC#MIT LicenseMIT

.NET NuGet

path

Path is a command-line tool to manage PATH environment variable on Windows. It's a successor to my PathCleaner project.

installation

Specifying version is required for pre-release projects on NuGet:

dotnet tool install path --global --version 0.1.2-alpha

why

PATH management in operating systems is inconsistent among platforms (even shells), and it's unnecessarily cumbersome. PATH variable gets cluttered over time too with many orphaned entries unnecessarily creating miniscule but non-zero overhead. This tool is mostly a UX experiment on how to make PATH management from command-line better. Although only Windows is supported currently, the ultimate goal is to make this tool the standard syntax for interacting with paths on any OS.

I also wanted to develop a tool with .NET 6 + System.CommandLine + Spectre.Console to learn more about them. I also learned a lot about GitHub Actions while coding this. Love all of them so far!

usage

Add a directory to user PATH:

path add C:\some\new\path

Want to add it to the machine-level PATH? Run this on an elevated prompt instead:

path add C:\some\new\path --global

Want to remove all instances of a directory from a PATH with a single command? Here it is:

path remove C:\some\existing\path\

Directories in PATH are searched in the order of addition. Want to move a directory higher up in the PATH? This command will move the directory to the beginning of the PATH:

path move C:\some\new\path top

Want to move a directory after another directory?

path move C:\some\new\path after C:\Windows

or before?

path move C:\som\new\path before C:\Windows

Over time, PATH might get cluttered with empty, orphaned folders without any executables in them. Use "analyze" command to find them:

path analyze

Analyze can also automatically fix the problems for you:

path analyze --fix

You might be scared of what fix will do, so you can run the same fix command with the --whatif argument:

path analyze --fix --whatif

warning

Messing with your PATH can easily cause your system to break or your applications to stop running. Use only if you know what you're doing. You've been warned.

license

MIT license. See LICENSE.md file for details.