aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclaw0ry <me@claw0ry.net>2025-01-21 16:05:11 +0100
committerclaw0ry <me@claw0ry.net>2025-01-21 16:05:11 +0100
commitb971ae25609d5f73413652c25d0741a2cb14ac29 (patch)
treec4a9781af4208dbd9652aac28ff24c8a98675db6
parentghostty: disable window-save-state (diff)
pwsh: improve hostname and spacing in prompt
-rw-r--r--powershell/Microsoft.PowerShell_profile.ps15
1 files changed, 4 insertions, 1 deletions
diff --git a/powershell/Microsoft.PowerShell_profile.ps1 b/powershell/Microsoft.PowerShell_profile.ps1
index dc824e1..574b323 100644
--- a/powershell/Microsoft.PowerShell_profile.ps1
+++ b/powershell/Microsoft.PowerShell_profile.ps1
@@ -26,7 +26,10 @@ if (Get-Command 'oh-my-posh' -ErrorAction 'SilentlyContinue') {
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) `e[1;35m$git_branch`e[00m`$ "
+ $hostname = [System.Net.Dns]::GetHostName().Split(".")[0]
+ $pathname = Split-Path -Path $pwd -Leaf
+ $path = if ($pathname -eq $env:USER) { "~" } else { $pathname }
+ "[pwsh] `e[01;32m$($env:USER)@$($hostname)`e[00m:`e[01;34m$($path) `e[1;35m$git_branch`e[00m`$ "
}
}