Created
July 10, 2026 16:35
-
-
Save ninmonkey/bec316176e699e6eec36e4707e4d3cff to your computer and use it in GitHub Desktop.
EditFunc - Jump to profile functions in Vs Code.ps1
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
| function EditFunc { | |
| <# | |
| .SYNOPSIS | |
| Finds where a function is defined, opens it in vs code -- and jumps to the line number it starts on | |
| .example | |
| gcm prompt | EditFunc | |
| #> | |
| [CmdletBinding()] | |
| param( | |
| [Parameter(ValueFromPipeline)] | |
| $Command | |
| ) | |
| begin { | |
| $binCode = Get-Command 'code' -CommandType Application -ea 'stop' -TotalCount 1 | |
| } | |
| process { | |
| $sb = (Get-Command $Command).ScriptBlock | |
| $fullName = Get-Item -ea 'stop' $sb.File | |
| $codeArgs = @( | |
| '--goto' | |
| '"{0}:{1}:{2}"' -f @( | |
| $fullName | |
| $sb.Ast.Extent.StartLineNumber | |
| $sb.Ast.Extent.StartColumnNumber | |
| ) | |
| ) | |
| & $binCode @codeArgs | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment