forked from jdhitsolutions/PSScriptTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSScriptTools.psm1
36 lines (30 loc) · 1.16 KB
/
PSScriptTools.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Get-ChildItem -path $PSScriptRoot\functions\*.ps1 | foreach-object -process {
. $_.FullName
}
#add ToDo options to the ISE or VS Code
if ($psEditor) {
$sb = {
Param(
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context
)
$prompt = "What do you need to do?"
$title = "To Do"
$item = Invoke-Inputbox -Title $title -Prompt $prompt
$todo = "# [$(Get-Date)] TODO: $item"
$context.CurrentFile.InsertText($todo)
}
Register-EditorCommand -Name "Insert.ToDo" -DisplayName "Insert ToDo" -ScriptBlock $sb -SuppressOutput
}
elseif ($psise) {
$action = {
$prompt = "What do you need to do?"
$title = "To Do"
$item = Invoke-Inputbox -Title $title -Prompt $prompt
$todo = "# [$(Get-Date)] TODO: $item"
$psise.CurrentFile.Editor.InsertText($todo)
#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("ToDo",$Action,"Ctrl+Alt+2" ) | Out-Null
}