Skip to content

Commit

Permalink
update profile and readme with new info for powershell (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Lautzenheiser <[email protected]>
  • Loading branch information
JasonLautzenheiser and Jason Lautzenheiser authored Apr 26, 2022
1 parent 24352f7 commit c94f506
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
32 changes: 15 additions & 17 deletions ps-profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c94f506

Please sign in to comment.