Last active
February 25, 2021 03:07
-
-
Save squaresmile/399a24209671788ba0ab850b148577a4 to your computer and use it in GitHub Desktop.
Powershell profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Prompt { | |
$loc = Get-Location | |
$title = $($loc.Drive.Root) | |
([uri]$loc.Path).segments | Select-Object -Skip 2 | Select-Object -SkipLast 1 | ForEach-Object { | |
$title = $title + $_.Substring(0, 1) + "\" | |
} | |
$leaf = $(Split-Path $loc.Path -Leaf) | |
# If the path is just the drive C:\ the leaf = title = C:\ | |
if ($title -ne $leaf) { | |
$title = $title + $leaf | |
} | |
$Host.UI.RawUI.WindowTitle = $title | |
"PS " + $title + "> " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: Full working directory
C:\Users\squaresmile\github\powershell
->C:\U\s\g\powershell
.