Skip to content

takekazuomi/posh-direnv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

posh-direnv

Inspired by direnv

https://github.com/direnv/direnv

posh-direnv is an environment switcher for the PowerShell. It executes ".psdirenv" in the current directory. You can easily set unique environment variables for each directory.

How to install

You can install from PowerShell Gallery. posh-direnv

$ Install-Module -Name posh-direnv

Usage

$ mkdir work
$ cd work
$ Edit-DirEnvRc

Since notepad starts up, edit .psdirenv. When you exit the editor .psdirenv is authorised and applied if the file was modified.

$ cat .\.psenvrc
Write-Host "Hello posh-direnv"
$Host.UI.RawUI.WindowTitle="posh-direnv"

Activate the new powershell and check its operation. If you move to a directory with .psdirenv, it will be displayed as below and the console title will be changed.

$ cd work
psenvdir: loading work/.psenvrc
Hello posh-direnv
psenvdir: export

Once you exit the directory tree and move again the environment changes will be reversed and reapplied if you reenter the directory.

If you edit the .psenvrc file yourself or move it between directories you must authorise it before it will be applied.

$ cd work
psenvdir: work/.psenvrc not in allow list
$ Approve-DirEnvRc
psenvdir: loading work/.psenvrc
Hello posh-direnv
psenvdir: export

You can unauthorise a .psenvrc file by calling Deny-DirEnvRc and cleanup the authorised list in the event directories are deleted before being denied by calling Repair-DirEnvAuth.

About

powershell directory environment switcher

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •