How to use PowerShell alias cd a spec directory?

前端 未结 2 607
猫巷女王i
猫巷女王i 2021-01-11 13:29

On Linux

alias cdt=\'cd /usr/a\'

make a alias that when I type

cdt

I change the workpath to /use/a

<
相关标签:
2条回答
  • 2021-01-11 14:01

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

    function cdt { set-location "F:\a" }
    
    0 讨论(0)
  • 2021-01-11 14:03

    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
    
    0 讨论(0)
提交回复
热议问题