1

On Linux with BASH or ZSH I can set an option for cdable_vars which allow me to define a shortcut for a folder.

For example:

export servo="/home/bleakcabal/Documents/servo/"

Lets me cd into this folder by doing:

cd servo

Is there something similar with Powershell? If so how do I do it?

1

Yes there is. Use the following code to create a system variable for the folder:

  [Environment]::SetEnvironmentVariable("TEMP1","C:\temp1","Machine")

Where TEMP1 is the system variable name. C:\temp1 is the path name.

You call it in Powershell with the $env:<variable_name> variable

enter image description here

0

A normal variable will do the job in PowerShell just as well as an environment variable.

PS C:\> $temp1 = '/temp1'
PS C:\> cd $temp1
PS C:\temp1> _

If you do really want to do it without the $ prefix, checkout cd-extras.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.