diff --git a/README.md b/README.md index 93d1869..9594a8b 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,9 @@ I use [oh-my-posh](https://ohmyposh.dev) for my custom prompt. Check out this g To make it look properly, you will need to download and install a Nerd Font that contains the icons used in oh-my-posh. Follow the instructions here: [oh-my-posh Nerd Fonts](https://ohmyposh.dev/docs/config-fonts) -oh-my-posh is updated very frequently with new features and bug fixes. I recommend keeping it updated. +oh-my-posh is updated very frequently with new features and bug fixes. I recommend keeping it updated. I recommend following the directions from the official repo for how to install and update. -Powershell to install an update -```powershell -Update-Module oh-my-posh -``` -the restart powershell or reload your profile. +> Note that if you installed oh-my-posh for powershell on windows prior to version 7.72, they have deprecated the powershell module and you should follow the instructions here: [oh-my-posh migrating](https://ohmyposh.dev/docs/migrating) If you using oh-my-posh with bash or some other shell your update procedure will be different. diff --git a/ps-profile.ps1 b/ps-profile.ps1 index 834ec1a..1f2cbce 100644 --- a/ps-profile.ps1 +++ b/ps-profile.ps1 @@ -5,28 +5,26 @@ if($ar.count -lt 1){ } #endregion Aliases -if (Get-Module oh-my-posh -ListAvailable) { - Import-Module oh-my-posh - $ohMyPoshConfigOriginal = 'C:\Apps\powershell\prompt\oh-my-config.json' - $ohMyPoshConfig = "$env:USERPROFILE\oh-my-config.json" +$ohMyPoshConfigOriginal = 'C:\Apps\powershell\prompt\oh-my-config.json' +$ohMyPoshConfig = "$env:USERPROFILE\oh-my-config.json" - try { - if (Test-Path $ohMyPoshConfig) { - $bak = "$ohMyPoshConfig.bak" - if (Test-Path $bak) { - Remove-Item $bak -Force - } - Copy-Item $ohMyPoshConfigOriginal $bak -Force - Remove-Item $ohMyPoshConfig -Force +try { + if (Test-Path $ohMyPoshConfig) { + $bak = "$ohMyPoshConfig.bak" + if (Test-Path $bak) { + Remove-Item $bak -Force } - Copy-Item $ohMyPoshConfigOriginal $ohMyPoshConfig -Force + Copy-Item $ohMyPoshConfigOriginal $bak -Force + Remove-Item $ohMyPoshConfig -Force } - catch { - Write-Warning "Unable to write oh-my-posh profile to $ohMyPoshConfig -- $($_)" - } - oh-my-posh init powershell --config $ohMyPoshConfig | Invoke-Expression + Copy-Item $ohMyPoshConfigOriginal $ohMyPoshConfig -Force +} +catch { + Write-Warning "Unable to write oh-my-posh profile to $ohMyPoshConfig -- $($_)" } +oh-my-posh init powershell --config $ohMyPoshConfig | Invoke-Expression + if (Get-Module Terminal-Icons -ListAvailable) { Import-Module Terminal-Icons }