Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use PowerShell alias cd a spec directory?

On Linux

alias cdt='cd /usr/a'

make a alias that when I type

cdt

I change the workpath to /use/a

On PowerShell

Set-Alias cdt "cd F://a"

It seems not work

like image 475
mingchaoyan Avatar asked Apr 18 '15 11:04

mingchaoyan


2 Answers

Aliases can't use parameters, so define a function instead.

function cdt { set-location "F:\a" }
like image 128
Bill_Stewart Avatar answered Sep 22 '22 07:09

Bill_Stewart


To make sure this stays as a permanent alias you can do the following in powershell:

notepad $profile

and paste the following in the file (at the end):

function gotoa { set-location "F:\a" }
new-alias cdt gotoa
like image 31
fireball.1 Avatar answered Sep 21 '22 07:09

fireball.1