All the content of this article referring to this awesome video by devaslife, check out his channel for detail steps and find more cool videos
Neccessary tools
1> WSL - Window terminal (from Microsoft store)
2> Powershell (from Microsoft store)
3> Scoop installer - check this
Install scoop
Make sure PowerShell 5 (or later, include PowerShell Core) and .NET Framework 4.5 (or later) are installed. Then run:
iwr -useb get.scoop.sh | iex
Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
Set PATH for scoop
command in System Properties
> Advanced
> Environment Variables
.
Add new directory path in System variables
> Path
, choose scoop directory C:\Users\<USERNAME>\scoop\shims
Close and reload terminal.
Install some neccessary packages via scoop
jq
is optional
Run
scoop install curl sudo jq
Install Nerd Fonts
- Got to this link and download
FuraCode
font from Nerd Fonts - Extract and right click >> Install the font.
Setup Window terminal
- Choose Powershell as default.
- Checkout appearance tab of Powershell and choose
FuraCode Nerd Font Retina
as default font. - Select Color scheme
One Half Dark
and enable Acrylic option with opacity 50% to have a better Window terminal display.
Install Neovim (optional)
Run
scoop install neovim gcc
Install some nice modules to improve powershell
1> posh-git
Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names.
Install-Module posh-git -Scope CurrentUser -Force
To import module run
Import-Module posh-git
(To import module automatically when shell starting need to set in User Profile, this can be found at the end of article, same for all modules)
2> oh-my-posh
Theming capabilities for the PowerShell prompt in ConEmu
Install-Module oh-my-posh -Scope CurrentUser -Force
To import module run
Import-Module oh-my-posh
Set Promt theme using
Set-PoshPromt -Theme <THEME_NAME>
THEME_NAME can be found here
3> Terminal Icons (display icons of folder/files)
Run
Install-Module -Name Terminal-Icons -Repository PSGallery -Force
To import module run
Import-Module Terminal-Icons
4> Z directory jumper
Jump easily between to recent directories with alias
Run
Install-Module -Name Z -Force
To jump just type z
+ any word
contain in recent directory used in cd
command, check the module for more detail.
5> PSReadLine - Autocompletion recent command on typing
run
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
Set PSREadLine option
Set-PSReadLineOption -PredictionSource History
6> Fuzzy finder
Run
scoop install fzf
And
Install-Module -Name PSFzf -Scope CurrentUser -Force
To import module run
Import-Module PSFzf
and
Set-PsFzfOption -PsReadLineChordProvider 'Ctrl+f' -PSReadLineChordReverseHistory 'Ctrl+r'
Custom oh-my-posh theme
You can customize the json config for oh-my-posh prompt, detail documentation can be found here, the json below was modified from M365Princess theme to personalize the colors & add new line command.
1 >> Create oh-my-post json file at ~/.config/powershell/<file-name>.omp.json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "session",
"style": "diamond",
"foreground": "#ffffff",
"background": "#031d44",
"leading_diamond": "\uE0B6",
"trailing_diamond": "",
"properties": {
"prefix": "",
"template": "{{ .UserName }}"
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#04395e",
"properties": {
"style": "folder"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#70a288",
"properties": {
"fetch_stash_count": true,
"fetch_upstream_icon": true,
"branch_icon": "",
"fetch_status": false,
"template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}",
"prefix": " \u279C (",
"postfix": ") "
}
},
{
"type": "php",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#4063D8",
"properties": {
"prefix": " \ue73d ",
"enable_hyperlink": false
}
},
{
"type": "node",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#dab785",
"properties": {
"prefix": " \uE718 "
}
},
{
"type": "time",
"style": "diamond",
"trailing_diamond": "\uE0B0",
"foreground": "#ffffff",
"background": "#d5896f",
"properties": {
"prefix": " \u2665 ",
"time_format": "15:04"
}
}
]
},
{
"type": "prompt",
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#007ACC",
"properties": {
"prefix": "",
"text": "\uE602"
}
}
]
}
],
"final_space": true
}
2 >> Load prompt config in user profile
With neovim installed run
nvim $PROFILE.CurrentsUserAllHosts
or open with any text edit
Add this line below to the file
oh-my-posh --init --shell pwsh --config 'C:\Users\<your-username>\.config\powershell\<you-file-name>.omp.json' | Invoke-Expression
3 >> Restart powershell and see result
Wrapping up all the import and option set in user profile
With neovim installed run
nvim $PROFILE.CurrentsUserAllHosts
Or open the file in any text editor, file path can be found by running:
echo $PROFILE.CurrentsUserAllHosts
Finalize user profile with some cool alias and function
Import-Module posh-git
Import-Module oh-my-posh
# PSReadLine
Set-PSREadLineOption -PredictionSource History
# Terminal-Icons
Import-Module Terminal-Icons
# Fzf
Import-Module PSFzf
Set-PsFzfOption -PSReadLineChordProvider 'Ctrl+f' -PSReadLineChordReverseHistory 'Ctrl+r'
# Set theme
Set-PoshPrompt -Theme M365Princess
# Load prompt configs
oh-my-posh --init --shell pwsh --config 'C:\Users\<your-username>\.config\powershell\<you-file-name>.omp.json' | Invoke-Expression
# Alias (Optional)
Set-Alias vim nvim
Set-Alias g git
Set-Alias ll ls
Set-Alias grep findstr
Set-Alias tig 'C:\Program Files\Git\usr\bin\tig.exe'
Set-Alias less 'C:\Program Files\Git\usr\bin\less.exe'
# Ultilities (Optional)
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
Top comments (6)
I have started a project that I think would be a great fit (it's not done yet but it is functional)
github.com/AnderssonPeter/PowerType it gives you autocomplete for cli tools, currently it only supports a subset of git.
Would love feedback!
Thanks for the your detail explanation, honestly Iβm not an expert with these kind of things so its nice to hear that, my post just try to keep everything as simple as it should so that everyone can start following and getting new things (just like me, I havenβt try powershell before till now)
WSL stand for "Windows Subsystem for Linux", it's for window terminal which you can install it via Microsoft Store, see below link for detail.
docs.microsoft.com/en-us/windows/w...