Skip to content

Instantly share code, notes, and snippets.

@jdhitsolutions
Last active June 6, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdhitsolutions/b37497344e8d5e71a769e0bc7bf5b341 to your computer and use it in GitHub Desktop.
Save jdhitsolutions/b37497344e8d5e71a769e0bc7bf5b341 to your computer and use it in GitHub Desktop.
Use this PowerShell function in the PowerShell ISE to change location to the directory of the currently selected file.
#requires -version 4.0
#requires -module ISE
<#
use this function in the PowerShell ISE to change location
to the directory of the currently selected file.
Learn more about PowerShell:
http://jdhitsolutions.com/blog/essential-powershell-resources/
#>
Function Set-ISELocation {
[cmdletbinding()]
Param()
#save current location so that you can pop back
Push-Location
#get the path from the currently select file in the ISE
$current = $psise.CurrentFile.FullPath
#split the path to get the parent path
$target = Split-Path -Path $current
#change location
Set-Location -path $target
}
#define an alias for the function
Set-Alias -Name jmp -Value Set-ISELocation
@jdhitsolutions
Copy link
Author

This function is described at http://bit.ly/1VIaBxL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment