Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create alias for path

Is it possible in PowerShell to create alias for path?

For example: I have to write all time

PS PS C:\Users\Jacek>cd C:\windows\microsoft.net\framework\v4.0.30319

I will happy if I could write

PS PS C:\Users\Jacek>cd dotNet4path
like image 393
Jacek Avatar asked Apr 27 '15 08:04

Jacek


2 Answers

You could just create a variable in your powershell profile with that path as the value.

Then all you would need to do is something like

cd $dotNet4path

To add something to your profile profile, type $profile, into a powershell window and it will display the path to your powershell profile file. Create it if it does not exist.

Then put this line in the file, save and restart powershell.

$dotNet4path = "C:\windows\microsoft.net\framework\v4.0.30319"
like image 161
DanL Avatar answered Nov 02 '22 23:11

DanL


you could use an alias to execute a custom function (you may want to do this in your profile) or use a psdrive :

function path2dotNet{cd "C:\Users\Jacek>cd C:\windows\microsoft.net\framework\v4.0.30319"}  
Set-Alias dot4 -Value path2doc

New-PSDrive dotnet -PSProvider FileSystem -Root "C:\Users\Jacek>cd C:\windows\microsoft.net\framework\v4.0.30319" 
cd dotnet:
like image 26
Loïc MICHEL Avatar answered Nov 03 '22 00:11

Loïc MICHEL