Ventajou
Ventajou

Reputation: 334

Is there a way to alter Powershell's environment path based on the current working directory?

So I have a code repository with some utility scripts under a Scripts folder. Whenever I want to run the utility script, I have to type:

./scripts/someScript.ps1 someParam

Is there a way for me to set the env:path so I only need to type:

someScript someParam

But only when the working directory is part of my local repository? So for example it would work when I'm in:

c:\code\project1
c:\code\project1\source

but not in

c:\code
c:\code\project2

Thanks!

Upvotes: 2

Views: 65

Answers (1)

Keith Hill
Keith Hill

Reputation: 201962

As @graimer mentions you can create a proxy function to override the default Set-Location (and cd) behavior. However an easier approach might be to just create some aliases. I do this to make sure I get a specific version of msbuild e.g.

New-Alias msbuild4 c:\windows\microsoft.net\framework\v4.0....\msbuild.exe

Upvotes: 1

Related Questions