User Tools

Site Tools


powershell_setup

PowerShell Setup

  1. Run Get-PSRepository to verify if PowerShell Gallery is set up properly. If it isn't, you probably need to set up the web proxy settings.
  2. Run Find-Module posh-git to verify that modules can be installed. If you get 'Unable to resolve package source…' you will need to install it manually (don't bother trying to fix it).
  3. Run Install-Module posh-git -Scope CurrentUser.
  4. Run Install-Module oh-my-posh -Scope CurrentUser.
  5. Run Install-Module -Name Terminal-Icons -Repository PSGallery.
  6. Run code $profile. Update to:
    Import-Module posh-git
    Import-Module oh-my-posh
    Set-PoshPrompt -Theme pure
    Import-Module -Name Terminal-Icons
    Write-Output "Powershell version $($PSVersionTable.PSVersion)"

Picking a Theme

Current favorites: pure (minimalist) or iterm2.

  • Open Windows Terminal.
  • Spit it with two PowerShell terminals.
  • In both, switch to an interesting directory, e.g. cd C:\Dev\Common\Auto Hot Key\
  • In one terminal, type Get-PoshThemes.
  • In the other, type Set-PoshPrompt -Theme whatever to play with it.

Screw it, use my own

  1. Create the file below at C:\Users\micro\AppData\Local\oh-my-posh\themes\tallguy.omp.json.
  2. Update the profile above with Set-PoshPrompt -Theme tallguy.
{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "final_space": true,
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{ .Shell }} in {{ .Folder }}",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#003544",
          "background": "#0087D8",
          "properties": {
            "prefix": " \uE5FF ",
            "style": "full",
            "folder_separator_icon": "\\"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "",
          "foreground": "#193549",
          "background": "#d2ff5e",
          "properties": {
            "display_stash_count": true,
            "display_upstream_icon": true,
            "status_colors_enabled": true,
            "display_status": true,
            "local_changes_color": "#ff9248",
            "ahead_and_behind_color": "#f26d50",
            "behind_color": "#f17c37",
            "ahead_color": "#89d1dc",
            "stash_count_icon": "\uF692 "
          }
        },
        {
          "type": "exit",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#242424",
          "background": "#33DD2D",
          "properties": {
            "display_exit_code": false,
            "always_enabled": true,
            "color_background": true,
            "error_color": "#f1184c",
            "prefix": " \ufc8d"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "battery",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B2",
          "foreground": "#242424",
          "background": "#f36943",
          "properties": {
            "battery_icon": "\f583",
            "color_background": true,
            "charged_color": "#0476d0",
            "charging_color": "#33DD2D",
            "discharging_color": "#FFCD58",
            "postfix": "\uF295 \uf583 "
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B2",
          "foreground": "#003544",
          "background": "#0087D8",
          "properties": {
            "prefix": " \uE235 ",
            "display_version": false,
            "display_mode": "context",
            "display_virtual_env": true
          }
        },
        {
          "type": "spotify",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#434343",
          "background": "#1BD760",
          "properties": {
            "prefix": " \uF9C6 "
          }
        },
        {
          "type": "time",
          "style": "powerline",
          "invert_powerline": true,
          "powerline_symbol": "\uE0B2",
          "foreground": "#fff",
          "background": "#003543",
          "properties": {
            "prefix": "<#fff> \uf64f </>"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "type": "root",
          "style": "plain",
          "foreground": "#FFD700",
          "properties": {
            "root_icon": "⚡"
          }
        },
        {
          "type": "text",
          "style": "plain",
          "foreground": "#808080",
          "properties": {
            "prefix": "",
            "text": ">"
          }
        }
      ]
    }
  ]
}
powershell_setup.txt · Last modified: 2022/03/21 22:50 by stephen