Skip to content

Instantly share code, notes, and snippets.

@davidmdem
Created November 19, 2015 17:34
Show Gist options
  • Select an option

  • Save davidmdem/61774388a2bc7bf8c819 to your computer and use it in GitHub Desktop.

Select an option

Save davidmdem/61774388a2bc7bf8c819 to your computer and use it in GitHub Desktop.
Custom PowerShell profile
##
# 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