-
Install latest Windows Terminal
winget install --id Microsoft.WindowsTerminal -e # or the very latest winget install --id Microsoft.WindowsTerminal.Preview -e
-
Install the latest Powershell (7.3.x)
winget install --id Microsoft.Powershell -s winget
-
Install OhMyPosh
winget install JanDeDobbeleer.OhMyPosh -s winget
-
Restart terminal or launch new window
wt.exe
-
Install NerdFont
oh-my-posh font install > meslo
It's recommended that you enable the latest text rendering engine in Windows Terminal Profiles -> Shell -> Advanced -> Use the new text renderer ("AtlasEngine")
-
Install PS-Readline
Install-Module PSReadLine -AllowPrerelease -Force
-
Update powershell profile settings in terminal (make it your default too)
// In settings set command line to new powershell "C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo // Alternately, open Json Settings File { "colorScheme": "One Half Dark", "commandline": "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" -NoLogo", "cursorShape": "filledBox", "elevate": true, "font": { "face": "MesloLGS Nerd Font", "size": 10.0 }, "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "Shell", "padding": "15", "source": "Windows.Terminal.PowershellCore", "useAtlasEngine": true },
-
Edit your powershell profile
code $Profile
- Paste in the content from Microsoft.Powershell_profile.ps1
- Copy 'MyPoshProfile.ps1' to a path you want to use for powershell scripts (default is Documents\Powershell)
- I've included the marcduiker.omp.json theme but it should be included with OhMyPosh
Last active
January 24, 2025 03:35
-
-
Save jakenuts/1f6787d4f82b66755efd59d01c554d23 to your computer and use it in GitHub Desktop.
Windows Terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
"blocks": [ | |
{ | |
"alignment": "left", | |
"segments": [ | |
{ | |
"background": "#feae34", | |
"foreground": "#262b44", | |
"leading_diamond": "\ue0b6", | |
"powerline_symbol": "\ue0b0", | |
"properties": { | |
"style": "folder" | |
}, | |
"style": "diamond", | |
"template": " \ue5ff {{ .Path }} ", | |
"trailing_diamond": "\ue0b0", | |
"type": "path" | |
}, | |
{ | |
"background": "#fee761", | |
"background_templates": [ | |
"{{ if or (.Working.Changed) (.Staging.Changed) }}#f77622{{ end }}", | |
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#e43b44{{ end }}", | |
"{{ if gt .Ahead 0 }}#2ce8f5{{ end }}", | |
"{{ if gt .Behind 0 }}#f77622{{ end }}" | |
], | |
"foreground": "#262b44", | |
"powerline_symbol": "\ue0b0", | |
"properties": { | |
"fetch_stash_count": true, | |
"fetch_status": true, | |
"fetch_upstream_icon": true | |
}, | |
"style": "powerline", | |
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ", | |
"type": "git" | |
}, | |
{ | |
"background": "#0095e9", | |
"background_templates": [ | |
"{{ if gt .Code 0 }}#ff0044{{ end }}" | |
], | |
"foreground": "#ffffff", | |
"leading_diamond": "<transparent,background>\ue0b0</>", | |
"properties": { | |
"always_enabled": true | |
}, | |
"style": "diamond", | |
"template": " \uf0e7 ", | |
"trailing_diamond": "\ue0b4", | |
"type": "exit" | |
} | |
], | |
"type": "prompt" | |
} | |
], | |
"final_space": true, | |
"version": 2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loads OhMyPosh Profile (replace C:\Code\Scripts\Powershell with whereever you want to store powershell scripts) | |
. "C:\Code\Scripts\PowerShell\Profiles\MyPoshProfile.ps1" | |
# Squelch extras in VSCode | |
if($env:TERM_PROGRAM -ne 'vscode') { | |
Write-Host 'π Enter `tips` for custom functions' | |
Write-Host '' | |
} | |
# Show custom functions | |
function tips { | |
Write-Host '' | |
Write-Host 'd - directory listing' | |
Write-Host 'b - launch browser' | |
Write-Host 'mdo - create and open directory' | |
Write-Host 'rdx - delete directory and contents without confirmations' | |
Write-Host 'ep - edit powershell profile in code' | |
Write-Host 'rmvs - remove all bin/obj folders below' | |
Write-Host 'rmnm - remove all node_modules folders below' | |
Write-Host 'upshell - update shell components' | |
Write-Host 'restart - restart computer (confirmed)' | |
Write-Host 'psinfo - show powershell, terminal, psreadline info' | |
Write-Host '---' | |
} | |
# Sets up p as the alias for pnpm | |
New-Alias p pnpm | |
# Alternate dir listing | |
function d { | |
#Get-ChildItem $args | Sort LastWriteTime -descending | Format-Table -Property @{e='LastWriteTime';Width=18;FormatString='MM/dd/yy HH:MM tt'}, @{Expression={({π},{π})[$PSItem.PSIsContainer]};Width=3}, @{e='Name';Width=70} -HideTableHeaders | |
Get-ChildItem $args | Sort -Property @{e="PSIsContainer";Ascending=$true}, @{e="LastWriteTime";Ascending=$false} | Format-Table -Property @{e='LastWriteTime';Width=18;FormatString='MM/dd/yy HH:MM tt'}, @{Expression={({π},{π})[$PSItem.PSIsContainer]};Width=3}, @{e='Name';Width=70} -HideTableHeaders -GroupBy $PSItem.PSIsContainer | |
} | |
# Make and open directory | |
function mdo { | |
$NewDir = New-Item -ItemType directory -Path $args | |
Set-Location $NewDir | |
} | |
# Remove directory and contents without confirmations | |
function rdx { | |
rd /s /q $args | |
} | |
# Edit your profile | |
function ep { | |
code $profile | |
} | |
# Remove VS intermediate folders | |
function rmvs { | |
Get-ChildItem .\ -include bin,obj -Recurse | ForEach-Object {rimraf $_.FullName} | |
} | |
# Remove node_modules folders | |
function rmnm { | |
Get-ChildItem .\ -include node_modules -Recurse | ForEach-Object {rimraf $_.FullName} | |
} | |
# Start browser | |
function b | |
{ | |
Start-Process MicrosoftEdge | |
} | |
# Start Visual Studio | |
function vs | |
{ | |
Start-Process "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe" . | |
} | |
# Restart Computer | |
function restart | |
{ | |
Restart-Computer -Confirm | |
} | |
# Update shell components | |
function upshell { | |
# Updates ai-shell, to install use - npm install -g @builder.io/ai-shell | |
ai update | |
# Updates OhMyPosh | |
winget upgrade JanDeDobbeleer.OhMyPosh -s winget | |
# Updates Windows Terminal | |
winget upgrade --id Microsoft.WindowsTerminal -e | |
#Update-Module -name PSReadLine -AllowPrerelease -Force -verbose -Scope CurrentUser | |
#Get-Module | Update-Module -Property Name | |
} | |
# Get all your Powershell details | |
function psinfo { | |
$hostName = $Host.Name | |
if ($hostName -eq "ConsoleHost" -and (Get-Command Get-CimInstance -ErrorAction SilentlyContinue)) { | |
$id = $PID; $inWindowsTerminal = $false | |
while ($true) { | |
$p = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId Like $id" | |
if (!$p -or !$p.Name) { break } | |
if ($p.Name -eq "WindowsTerminal.exe") { $inWindowsTerminal = $true; break } | |
$id = $p.ParentProcessId | |
} | |
if ($inWindowsTerminal) { $hostName += " (Windows Terminal)" } | |
} | |
$m = Get-Module PSReadline | |
$v = $m.Version; $pre = $m.PrivateData.PSData.Prerelease | |
if ($pre) { $v = "$v-$pre" } | |
$os = if ($IsLinux -or $IsMacOS) { uname -a } else { (dir $env:SystemRoot\System32\cmd.exe).VersionInfo.FileVersion } | |
Write-Host '' | |
Write-Host "PS Version: $($PSVersionTable.PSVersion)" | |
Write-Host "PS HostName: $hostName" | |
Write-Host "PSReadLine Version: $v" | |
Write-Host "PSReadLine EditMode: $((Get-PSReadLineOption).EditMode)" | |
Write-Host "OS: $os" | |
Write-Host "BufferWidth: $([console]::BufferWidth)" | |
Write-Host "BufferHeight: $([console]::BufferHeight)" | |
Write-Host '' | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation | |
using namespace System.Management.Automation.Language | |
if ($host.Name -eq 'ConsoleHost') | |
{ | |
###################### | |
# PSREADLINE | |
Import-Module PSReadLine | |
Set-PSReadLineOption -PredictionSource History | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
Set-PSReadLineOption -EditMode Windows | |
} | |
##################### | |
# OH MY POSH | |
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\marcduiker.omp.json" | Invoke-Expression | |
oh-my-posh init pwsh --config "$PSScriptRoot\MyPoshTheme.omp.json" | Invoke-Expression | |
###################### | |
# DOTNET-SUGGEST | |
# enable dotnet-suggest command line completion for System.CommandLine based tools | |
#. $PSScriptRoot\Scripts\dotnet-suggest-shim.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screenshot