Skip to content

PowerShell

Find binary location like unix which

gcm \<latex\> | select Source

Restart Session

. $PROFILE
or
powershell.exe -noprofile

Update powershell

Open powershell in administrative mode and enter this command

winget upgrade powershell

Alias for Powershell

Get List

gal

Set an Alias

Temporary

Set-Alias -Name tf -Value terrafrom

Set powershell profile config C:\Users\<YourUsername>\Documents\PowerShell\profile.ps1

notepad++ C:\Users\mehrdad\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
add Set-Alias -Name ...  line

Remove an Alias

Remove-Item Alias:tf

Disable Bell alert in terminal

  • open the json file in setting section
  • add this key & value to json file
 "profiles":
    {
        "defaults":
        {
            "bellStyle": "none",
             ...

Active powershell profile

Set-ExecutionPolicy RemoteSigned

Fish-like Autosuggestion in Powershell

I. First, install ´PSReadLine´ version 2.1.0

   Install-Module PSReadLine -RequiredVersion 2.1.0

II. Then, initialize it with the command below(notepad $profile)

   Import-Module PSReadLine
   Set-PSReadLineOption -PredictionSource History

oh-my-posh

Installation

winget install JanDeDobbeleer.OhMyPosh -s winget

Clone oh-my-posh Themes

Active Custom Theme

Show the path of the current profile

echo $PROFILE

Open the active profile

notepad++ $profile

Edit these lines

oh-my-posh init pwsh --config C:\Users\mehrdad\oh-my-posh\themes\mehrdad.omp.json | Invoke-Expression

Language Segment