Forked from DamianEdwards/Microsoft.PowerShell_profile.ps1
Created
March 21, 2026 17:07
-
-
Save paulczy/4cd23dba22f8815691c24c57d6bb4c2a to your computer and use it in GitHub Desktop.
PowerShell Profile & oh-my-posh theme
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", | |
| "version": 2, | |
| "console_title_template": "{{if .Root}}(Admin) {{end}}{{.Folder}}", | |
| "blocks": [ | |
| { | |
| "type": "prompt", | |
| "alignment": "left", | |
| "segments": [ | |
| { | |
| "type": "root", | |
| "style": "plain", | |
| "foreground": "#f1184c", | |
| "template": " \uf0e7 " | |
| }, | |
| { | |
| "type": "os", | |
| "style": "plain", | |
| "foreground": "#3A86FF", | |
| "template": "{{ if .WSL }}WSL at {{ end }}{{.Icon}} " | |
| }, | |
| { | |
| "type": "time", | |
| "style": "plain", | |
| "foreground": "#FFBB00", | |
| "template": " {{ .CurrentDate | date .Format }} ", | |
| "properties": { | |
| "time_format": "15:04:05" | |
| } | |
| }, | |
| { | |
| "type": "text", | |
| "style": "powerline", | |
| "powerline_symbol": "\ue0c4", | |
| "foreground": "#ffffff", | |
| "background": "#5C2D91", | |
| "template": "{{if .Env.VSCMD_VER}} \udb81\ude10 {{.Env.VSCMD_VER}} {{ end }}" | |
| }, | |
| { | |
| "type": "path", | |
| "style": "plain", | |
| "foreground": "#33DD2D", | |
| "template": " \ue5ff {{ .Path }} ", | |
| "properties": { | |
| "folder_separator_icon": "/", | |
| "style": "agnoster_short" | |
| } | |
| }, | |
| { | |
| "type": "git", | |
| "style": "plain", | |
| "foreground": "#3A86FF", | |
| "template": "{{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf0c7 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }}", | |
| "properties": { | |
| "fetch_stash_count": true, | |
| "fetch_status": true, | |
| "fetch_upstream_icon": true | |
| } | |
| }, | |
| { | |
| "type": "dotnet", | |
| "style": "powerline", | |
| "powerline_symbol": "\ue0c4", | |
| "foreground": "#ffffff", | |
| "background": "#512BD4", | |
| "template": " \udb82\udeae {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }} " | |
| }, | |
| { | |
| "type": "executiontime", | |
| "style": "powerline", | |
| "powerline_symbol": "\ue0c4", | |
| "foreground": "#ffffff", | |
| "background": "#0184bc", | |
| "template": " <#fefefe>\uf520</> {{ .FormattedMs }} ", | |
| "properties": { | |
| "style": "austin", | |
| "threshold": 1 | |
| } | |
| }, | |
| { | |
| "type": "exit", | |
| "style": "powerline", | |
| "powerline_symbol": "\ue0c4", | |
| "foreground": "#242424", | |
| "background": "#33DD2D", | |
| "background_templates": [ | |
| "{{ if gt .Code 0 }}#f1184c{{ end }}" | |
| ], | |
| "template": " \udb82\udfea " | |
| } | |
| ] | |
| }, | |
| { | |
| "type": "prompt", | |
| "alignment": "left", | |
| "segments": [ | |
| { | |
| "type": "text", | |
| "style": "plain", | |
| "foreground": "#f1184c", | |
| "template": "➜ " | |
| } | |
| ], | |
| "newline": true | |
| } | |
| ] | |
| } |
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
| function Get-ProgramFiles32() { | |
| if ($null -ne ${env:ProgramFiles(x86)}) { | |
| return ${env:ProgramFiles(x86)} | |
| } | |
| return $env:ProgramFiles | |
| } | |
| function Get-VsInstallLocation() { | |
| $programFiles = Get-ProgramFiles32 | |
| $vswhere = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe" | |
| if (Test-Path $vswhere) { | |
| $vsinstallpath = (. "$vswhere" -latest -prerelease -property installationPath -format value -nologo | Out-String).Trim() | |
| return $vsinstallpath | |
| } | |
| return $null; | |
| } | |
| # Visual Studio Developer PowerShell | |
| function Enable-VsShell() { | |
| $vsInstallPath = Get-VsInstallLocation | |
| if ($null -ne $vsInstallPath) { | |
| Import-Module "$vsInstallPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" | |
| Enter-VsDevShell -SkipAutomaticLocation -InstallPath $vsinstallpath | Out-Null | |
| } | |
| else { | |
| Write-Host "Visual Studio not found" | |
| } | |
| } | |
| if ($host.Name -eq 'ConsoleHost') { | |
| Import-Module PSReadLine | |
| [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new() | |
| } | |
| Import-Module posh-git, PSColors, Terminal-Icons | |
| # PowerShell parameter completion shim for the dotnet CLI | |
| $dotnetPath = Get-Command dotnet -ErrorAction SilentlyContinue | |
| if (!($null -eq $dotnetPath)) { | |
| $dotnetVersion = dotnet --version | |
| if ($dotnetVersion.StartsWith('10.0.100')) { | |
| # .NET 10 | |
| (dotnet completions script pwsh) | Out-String | Invoke-Expression -ErrorAction SilentlyContinue | |
| } | |
| else { | |
| # .NET <10 | |
| Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { | |
| param($commandName, $wordToComplete, $cursorPosition) | |
| dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object { | |
| [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
| } | |
| } | |
| } | |
| } | |
| # This is an example of a macro that you might use to execute a command. | |
| # This will add the command to history. | |
| # Set-PSReadLineKeyHandler -Key Ctrl+Shift+b ` | |
| # -BriefDescription BuildCurrentDirectory ` | |
| # -LongDescription "Build the current directory" ` | |
| # -ScriptBlock { | |
| # [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | |
| # [Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet build") | |
| # [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() | |
| # } | |
| Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
| # Enable UTF-8 in the console | |
| [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new() | |
| # Initialize oh-my-posh | |
| $ohmyposhProfile = "$PSScriptRoot\craver-vs.omp.json" | |
| if (Test-Path D:\src\craver-vs.omp.json) { | |
| $ohmyposhProfile = "D:\src\craver-vs.omp.json" | |
| } | |
| oh-my-posh init pwsh --config "$ohmyposhProfile" | Invoke-Expression | |
| # Alias bombbardier | |
| if (Test-Path C:\tools\bombardier-windows-amd64.exe) { | |
| Set-Alias bomb C:\tools\bombardier-windows-amd64.exe | |
| } | |
| elseif (Test-Path D:\tools\bombardier-windows-amd64.exe) { | |
| Set-Alias bomb D:\tools\bombardier-windows-amd64.exe | |
| } | |
| # Remove the 'where' alias | |
| Remove-Item alias:\where -Force -ErrorAction SilentlyContinue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment