Skip to content

Instantly share code, notes, and snippets.

@NickCraver
Last active March 18, 2024 13:25
Show Gist options
  • Star 56 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save NickCraver/2d661e24e315e7e94a1aad88dadfadf3 to your computer and use it in GitHub Desktop.
Save NickCraver/2d661e24e315e7e94a1aad88dadfadf3 to your computer and use it in GitHub Desktop.
Craver's oh-my-posh profile

This is the PowerShell profile I use - my theme is now built into oh-my-posh as "craver". Overall, to get this:

preview

You'll need only these instructions - all other files in this gist are for reference only:

  1. Optional (not needed in Windows 11):
    • Install Windows Terminal from the Microsoft Store...but this works in any Powershell terminal.
  2. The PowerShell modules:
    Install-Module -Name posh-git,oh-my-posh,Terminal-Icons -Repository PSGallery
  3. Edit your Microsoft.PowerShell_profile.ps1 file to these 3 modules and set the prompt (this executes when you start a PowerShell terminal). The path for this is $profile in PowerShell, e.g. to edit with VS Code: code $profile:
    Import-Module -Name posh-git,oh-my-posh,Terminal-Icons
    Set-PoshPrompt -Theme craver
  4. You'll also need a font capable of rendering the symbols, I use Delugia Nerd Font (download: https://github.com/adam7/delugia-code) - other options like Hack NF and others work well too.
    • To select this after install, go to Terminal's Settings -> Profiles: PowerShell (bottom left) -> Appearance tab, choose font
    • looks like this
  5. For the grey background, in the same area as step 2 choose "One Half Dark".

I hope you enjoy!

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{if .Root}}(Admin) {{end}}{{.Folder}}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "root",
"style": "powerline",
"powerline_symbol": "\uE0C4",
"foreground": "#242424",
"background": "#f1184c",
"properties": {
"prefix": "",
"postfix": ""
}
},
{
"type": "os",
"style": "diamond",
"leading_diamond": " ",
"powerline_symbol": "",
"foreground": "#3A86FF",
"background": "#282c34",
"properties": {
"prefix": ""
}
},
{
"type": "time",
"style": "powerline",
"powerline_symbol": "\uE0C4",
"foreground": "#FFBB00",
"background": "#242424",
"properties": {
"time_format": "15:04:05",
"prefix": ""
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#33DD2D",
"background": "#242424",
"properties": {
"prefix": "\uE5FF ",
"style": "folder",
"folder_separator_icon": "/"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#3A86FF",
"background": "#242424",
"properties": {
"display_status": true,
"display_stash_count": true,
"display_upstream_icon": true,
"prefix": ""
}
},
{
"type": "dotnet",
"style": "powerline",
"powerline_symbol": "\uE0C4",
"foreground": "#ffffff",
"background": "#0184bc",
"properties": {
"prefix": "  "
}
},
{
"type": "executiontime",
"style": "powerline",
"powerline_symbol": "\uE0C4",
"foreground": "#ffffff",
"background": "#8800dd",
"properties": {
"threshold": 10,
"style": "austin",
"prefix": " <#fefefe>\ufbab</> "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "\uE0B4",
"foreground": "#242424",
"background": "#33DD2D",
"properties": {
"display_exit_code": false,
"color_background": true,
"error_color": "#f1184c",
"prefix": " \ufc8d"
}
}
]
},
{
"type": "prompt",
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#f1184c",
"properties": {
"prefix": "",
"text": "\u279C"
}
}
]
}
]
}
# This goes in your Microsoft.PowerShell_profile.ps1 (can find the path via $PROFILE in your prompt)
Import-Module -Name posh-git,oh-my-posh,Terminal-Icons
Set-PoshPrompt -Theme craver
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"profiles":
{
"defaults": {},
"list":
[
{
"acrylicOpacity": 0.94999999999999996,
"closeOnExit": "graceful",
"colorScheme": "Craver",
"commandline": "powershell.exe",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"font":
{
"face": "Delugia Nerd Font",
"size": 10
},
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"historySize": 9001,
"icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
"name": "PowerShell",
"padding": "8",
"snapOnInput": true,
"startingDirectory": "C:\\git",
"useAcrylic": true
}
]
},
"schemes":
[
{
"background": "#1F2329",
"black": "#1F2329",
"blue": "#5498D1",
"brightBlack": "#5A6374",
"brightBlue": "#61AFEF",
"brightCyan": "#56B6C2",
"brightGreen": "#98C379",
"brightPurple": "#C678DD",
"brightRed": "#E06C75",
"brightWhite": "#DCDFE4",
"brightYellow": "#E5C07B",
"cursorColor": "#FFFFFF",
"cyan": "#56B6C2",
"foreground": "#DCDFE4",
"green": "#98C379",
"name": "Craver",
"purple": "#C678DD",
"red": "#E06C75",
"selectionBackground": "#FFFFFF",
"white": "#DCDFE4",
"yellow": "#E5C07B"
}
]
}
@CJHarmath
Copy link

awesome - thanks for sharing @NickCraver

@Bogatinov
Copy link

Bogatinov commented Sep 17, 2021

Thank you, loving it so far :)

I had some hurdles getting to setup

Tutorial

  1. Install Windows Terminal from Microsoft Store (also works on Powershell)

  2. Open Terminal in Administrator mode to execute the following commands

    • installs Posh git + icons for your terminal + a way to customize your prompt
Install-Module -Name posh-git -Repository PSGallery
Install-Module -Name oh-my-posh -Repository PSGallery
Install-Module -Name Terminal-Icons -Repository PSGallery
  1. Download craver.omp.json and Microsoft.PowerShell_profile.ps1 files

    • .json file is your prompt profile
    • .ps1 file is setup the profile on initialization of Terminal
  2. Save the files in ~\Documents\WindowsPowerShell to automatically execute on opening the Terminal

  3. Download the Nerd Font of your choice, to render the symbols in the terminal

  4. Open Terminal and change the Font in settings

Terminal's Settings -> PowerShell settings -> Appearance tab, choose font

Update#1 - theme is built-in oh-my-posh

Craver theme is built-in as part of oh-my-posh module, so it's no longer necessary to download the craver.omp.json file to save it locally.

You may, if you like tinkering with it 😄

  1. Update oh-my-posh module with -Force flag to receive the latest updates
Install-Module -Name oh-my-posh -Repository PSGallery -Force
  1. Update Microsoft.PowerShell_profile.ps1 with the built-in theme, instead of the file path
  2. Delete craver.omp.json file
  3. Open Terminal to see the new things 😄

and then if you like to use some of the settings in snippet-settings.json

  1. Open Terminal -> Settings -> Add a new profile
  2. Open JSON file to edit your custom profile
  3. Copy the values from snippet-settings.json
  4. Close and open terminal

Note: You may experience weird symbols since the settings depend on Delugia Nerd Font and my machine couldn't render some of the symbols like dotNET logo, even after re-installing the font.

@Gh0stWalk3r
Copy link

Actually it is better to check where the PowerShell profile is loaded from by executing $PROFILE.
In PowerShell 7.x you will get a different path (~\Documents\PowerShell) compared to pre-installed Windows PowerShell (~\Documents\WindowsPowerShell).

@joergbattermann
Copy link

Thanks for sharing @NickCraver / @Bogatinov! I got one small issue though and maybe someone knows / has a quick fix for it:

Despite installing the 3 PS modules and using Delugia Nerd Font (both.. the one Nick linked to as well as the Github one) I still get the character missing squares in the output, i.e.:

image

Would anyone know what's missing there? Thanks! -jB

@Gh0stWalk3r
Copy link

A small thing I added to my Microsoft.PowerShell_profile.ps1: dotnet and winget tab-to-complete feature:

# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
        dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
           [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}

# PowerShell parameter completion shim for the winget CLI
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)
        [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
        $Local:word = $wordToComplete.Replace('"', '""')
        $Local:ast = $commandAst.ToString().Replace('"', '""')
        winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}

@NickCraver
Copy link
Author

@joergbattermann Not sure what you're hitting there, try another font like Hack NF? From Hack.zip here: https://github.com/ryanoasis/nerd-fonts/releases

@NickCraver
Copy link
Author

@Bogatinov thanks for the feedback! I tried too improve the instructions here and simplified since it's a built-in theme now :)

@mgasparel
Copy link

We must get the dotnet bot icon patched into nerdfonts!

@edgarronda
Copy link

edgarronda commented Sep 21, 2021

In windows Delugia font doesn't work properly for me,
So I used Agave Nerd Font from @Bogatinov link https://www.nerdfonts.com/font-downloads

Now It's working so well.

image

@DiomedesDominguez
Copy link

Any equivalent to Terminal-Icons but instead of Powershell, to Bash?

@juchom
Copy link

juchom commented Mar 20, 2023

@DiomedesDominguez you can try this : https://www.youtube.com/watch?v=YnGl9SDVn98

@NickCraver Installing oh-my-posh with Install-Module is no longer supported
To install you have to use : winget install JanDeDobbeleer.OhMyPosh -s winget

And Microsoft.PowerShell_profile.ps1 shoud be like this now :

Import-Module -Name posh-git,Terminal-Icons
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\craver.omp.json" | Invoke-Expression

I think that's all I've done, thanks for this nice theme 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment