I want to include something in my PowerShell profile loading script that makes it very easy for me to navigate across different folders (different code repositories).
I've seen examples that uses New-PSDrive but I thought aliases is a smoother way of doing it. Aliases just feels better.
I'm looking for something like this:
(In profile.ps1)
New-Item alias:foo -value c:\repos\my\code\here
... Later on in the in the powershell console ...:
cd $foo
And voila! I'm now standing in the c:\repos\my\code\here
directory.
What's the right approach?
EDIT: I've marked Martins answer as accecpted as its very straight to the point, however I recommend you also read Matt's answer, it has some great points.
I would create a $repos
hashtable containing all your repositories:
$repos = @{
angular = 'c:\repos\my\angular\here'
typescript = 'c:\repos\my\typescript\here'
csharp = 'c:\repos\my\csharp\here'
}
Put this in your $profile
and you can change the directories like this:
cd $repos.angular
And even use tab-completion!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With