简体   繁体   中英

Saving Aliases for powershell in Visual Studio code

I'm pretty new to both visual studio code and PowerShell, mostly used gitBash before. I'm just wondering if there is a way to save aliases that I set in the powershell, so I don't have to redo them everytime I restart the application.

I tried a few google searches but could not find the answer to my question.

Thank you.

S

If you're using Visual Studio Code with the PowerShell extension , you're using the PIC (PowerShell-Integrated Console) in the Visual Studio Code's integrated terminal, which has its own $PROFILE file , separate from stand-alone PowerShell installations.

You can open this $PROFILE file from the PIC as follows:

psedit $PROFILE
  • Any alias definitions or functions you place in there will be available in future PIC sessions by default - but only there.

  • Alternatively, to share definitions with a stand-alone PowerShell installation, dot-source its $PROFILE file; eg, to dot-source:

    • the current user's Windows PowerShell profile, use:

       . ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
    • the current user's PowerShell (Core) 7+ profile, use:

       . ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM