Created
November 19, 2015 17:34
-
-
Save davidmdem/61774388a2bc7bf8c819 to your computer and use it in GitHub Desktop.
Custom PowerShell profile
This file contains hidden or 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
| ## | |
| # If the clipboard contains a directory path or a file path, | |
| # default the cwd to that path. Otherwise, default to `D:\`. | |
| # | |
| # Requires PowerShell 5 | |
| ## | |
| $clip = Get-Clipboard | |
| $location = "D:\" | |
| if (-not ( [string]::IsNullOrEmpty($clip) ) ) | |
| { | |
| if ( Test-Path -Path $clip -PathType Leaf ) | |
| { | |
| $location = Split-Path $clip | |
| } | |
| elseif( Test-Path -Path $clip -PathType Container ) | |
| { | |
| $location = $clip | |
| } | |
| } | |
| Set-Location $location | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment