DEV Community

Kazuki Okamoto
Kazuki Okamoto

Posted on

Path Environment Variable Quick Switcher for PowerShell

You may want to turn on and off the PATH environment variable, for example, when you use UNIX tools with MSYS2.

It's annoying like this.

» $prevPath = $Env:Path
» $Env:Path = "$Env:MSYS2\bin;$Env:MSYS2\mingw64\bin;$Env:Path"
» # do some work with MSYS2
» $Env:Path = $prevPath
Enter fullscreen mode Exit fullscreen mode

Or you may want to change each version of compilers.

powershell-path-switcher supports this.

GitHub logo kakkun61 / powershell-path-switcher

Path Environment Variable Quick Switcher

powershell-path-switcher

GitHub Actions: install GitHub Actions: lint PowerShell Gallery Sponsor

Path Environment Variable Quick Switcher.

JFyT6Gn0gm2n2m60.mp4

Install

> Install-Module path-switcher
> Import-Module path-switcher

PowerShell Gallery

Interactive select

A quick view is at this video.

Prepare a configuration file,

# $Env:ProgramData\powershell-path-switcher\config.yaml
msys2-usr:     C:\tools\msys64\usr\bin
msys2-mingw64: C:\tools\msys64\mingw64\bin
Enter fullscreen mode Exit fullscreen mode

and invoke Switch-Path.

» Switch-Path
> [ ] msys2-usr: C:\tools\msys64\usr\bin
  [ ] msys2-mingw64: C:\tools\msys64\mingw64\bin
Enter fullscreen mode Exit fullscreen mode

You can move its cursor (>) up/down with ↑/↓ keys, select (check by x) with the space key and reflect with the enter key.

When you want to remove a specified path from the PATH variable, you can delete it by removing its check mark (x).

For more information see a README.

Top comments (0)