TL;DR
This is a note that I found out Microsoft PowerShell can act like Bash/Zsh which I much familiar with. Because of the work, pretty much whole operating system move to windows. It is so much pain to work without using any shell. The main reason is that I so much used to use (neo)vim as my code editor. But luckily (neo)vim built for windows (phew~). Ok, back to the title, this is a step by step note that I dig into PowerShell and Windows.
Create
$PROFILEfor PowerShell if not exist (like.bashrcor.zshrc)- Test if Profile exist
1Test-Path $PROFILE
❗If return is false meaning there is NO profile found then jump to step 2. ❗If return is true meaning there IS profile found then jump to step 3.
- Create Profile
1New-Item -Type File -Force $PROFILE
⚠ (Caution) these will erase the exist profile with new empty one.
- Varify Profile path
1echo $PROFILE
It normally locate in
~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1- Test if Profile exist
Install
oh-my-poshTheme like powerlevel10kInstallation
1Install-Module oh-my-posh -Scope CurrentUserList all themes and remember the name of theme you like
1Get-PoshThemes -listAdd theme to Profile
1Set-PoshPrompt -Theme <Theme name>
Personally I use
honukaifor the simplicity.- Source the Profile or restart the Terminal to take effect.
1. $PROFILE
Install Autosuggestion
Installation
1Install-Module PSReadLineAdd the following configurations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15# autocompletion Import-Module PSReadLine Set-PSReadLineOption -PredictionSource History Set-PSReadLineKeyHandler -Chord Shift+Tab -Function AcceptSuggestion # Accept Suggestion # Autocompletion for arrow keys Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete # Iterate through autocompletion Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward # Bash like movement Set-PSReadlineKeyHandler -Chord ctrl+d -Function ViExit Set-PSReadlineKeyHandler -Chord ctrl+w -Function BackwardDeleteWord Set-PSReadlineKeyHandler -Chord ctrl+e -Function EndOfLine Set-PSReadlineKeyHandler -Chord ctrl+a -Function BeginningOfLine
Tab Completion Ref