Last active
June 6, 2016 16:52
-
-
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.
This file contains 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
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This function is described at http://bit.ly/1VIaBxL