From fdf67d28f0ab1a19419838cccfb1e6e0546067a2 Mon Sep 17 00:00:00 2001 From: claw0ry Date: Wed, 18 Dec 2024 16:37:39 +0100 Subject: powerhsell: set custom prompt if oh-my-posh not available --- powershell/Microsoft.PowerShell_profile.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/powershell/Microsoft.PowerShell_profile.ps1 b/powershell/Microsoft.PowerShell_profile.ps1 index 2545417..7f247ec 100644 --- a/powershell/Microsoft.PowerShell_profile.ps1 +++ b/powershell/Microsoft.PowerShell_profile.ps1 @@ -18,15 +18,25 @@ if ($IsWindows) { # - PROMPT - # ----------------------------------------------------------------------------- -oh-my-posh init pwsh --config "$env:XDG_CONFIG_HOME/oh-my-posh/config.yml" | Invoke-Expression +if (Get-Command 'oh-my-posh' -ErrorAction 'SilentlyContinue') { + oh-my-posh init pwsh --config "$env:XDG_CONFIG_HOME/oh-my-posh/config.yml" | Invoke-Expression +} else { + function prompt { + $git_branch = $(git branch --show-current 2>/dev/null) + if ($git_branch -ne $null -and $git_branch -ne "") { + $git_branch = "($($git_branch))" + } + "[pwsh] `e[01;32m$($env:USER)@$([System.Net.Dns]::GetHostName())`e[00m:`e[01;34m$(Split-Path -Path $pwd -Leaf) $git_branch`e[00m`$ " + } +} # ----------------------------------------------------------------------------- # - ENVIRONMENT VARIABLES - # ----------------------------------------------------------------------------- $env:PATH += ":$env:HOME/go/bin" -$env:EDITOR = "nvim" -$env:VISUAL = "nvim" +$env:EDITOR = "vim" +$env:VISUAL = "code" # ----------------------------------------------------------------------------- # - CUSTOM FUNCTIONS - -- cgit v1.2.3