util/Path.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

function Get-ShortenedPath {
    param (
        [Parameter(Mandatory = $true, Position = 1)] [String] $path
    )

    $result = $path;

    if (($Global:ColorSettings.General.ShortenUserFolder -eq $true) -and ($path.StartsWith($env:USERPROFILE))) {
        $result = $path.Replace($env:USERPROFILE, "~");
    }

    return $result;
}