Skip to content

Instantly share code, notes, and snippets.

@mattbalzan
Last active January 24, 2025 16:00
Show Gist options
  • Save mattbalzan/fef7d318a9abb60b82f27c420ebd580a to your computer and use it in GitHub Desktop.
Save mattbalzan/fef7d318a9abb60b82f27c420ebd580a to your computer and use it in GitHub Desktop.
PS ISE Editor Custom Add-On
$action1 = {
$psise.CurrentFile.Editor.InsertText("# --[ ]")
# Get the current cursor position
$currentLine = $psISE.CurrentFile.Editor.CaretLine
$currentColumn = $psISE.CurrentFile.Editor.CaretColumn
# Calculate the new column position
$newColumn = [math]::Max(1, $currentColumn - 2)
# Set the cursor to the new position
$psISE.CurrentFile.Editor.SetCaretPosition($currentLine, $newColumn)
}
# Add the action to the Add-Ons menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("mattGPT Comment",$Action1,"Alt+2" ) | Out-Null
$action2 = {
$psise.CurrentFile.Editor.InsertText("# --[ ]`n# --[ Matt Balzan | mattGPT.co.uk | $((Get-Date).ToShortDateString()) ]`n`n")
# Jump cursor to the end
$psise.CurrentFile.editor.SetCaretPosition($psise.CurrentFile.Editor.CaretLine,$psise.CurrentFile.Editor.CaretColumn)
}
# Add the action to the Add-Ons menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("mattGPT Title",$Action2,"Alt+1" ) | Out-Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment