functions/explorer/Backup-PSULocation.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function Backup-PSULocation
{
<#
    .SYNOPSIS
        Sets the location n number of levels up.
     
    .DESCRIPTION
        You no longer have to cd ..\..\..\..\ to move back four levels. You can now
        just type bu 4
     
    .PARAMETER Levels
        Number of levels to move back.
     
    .EXAMPLE
        PS C:\Users\dlbm3\source\pullrequests\somePR\vsteam> bu 4
         
        PS C:\Users\dlbm3>
     
    .NOTES
        Author: Donovan Brown
        Source: http://donovanbrown.com/post/Why-cd-when-you-can-just-backup
     
        Thank you for sharing and granting permission to use this convenience :)
#>

    [CmdletBinding()]
    param (
        [int]
        $Levels = (Get-PSFConfigValue -FullName 'PSUtil.Path.BackupStepsDefault' -Fallback 1)
    )
    
    Set-Location -Path (,".." * $Levels | Join-PSUString -With ([System.IO.Path]::DirectorySeparatorChar))
}

Import-PSUAlias -Name "bu" -Command "Backup-PSULocation"