From c38785cbf5baef08264c7a0c6e5b94ef0317b6ac Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Wed, 12 May 2021 09:29:18 -0400 Subject: [PATCH] Edit-MyScript fix for Windows/PS5.1 When calling Edit-TextFile wihtout explicitly specifying -Path, multiple files in command line would be passed on to editor incorrectly, with the -Path explicitly specified, this now works in all versions of PowerShell --- base/Edit-MyScript.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/base/Edit-MyScript.ps1 b/base/Edit-MyScript.ps1 index c61f2f4..d049607 100644 --- a/base/Edit-MyScript.ps1 +++ b/base/Edit-MyScript.ps1 @@ -83,11 +83,12 @@ foreach( $local:p in $ScriptPaths ) { } $local:sw = [System.Diagnostics.Stopwatch]::StartNew(); -Edit-TextFile $ScriptPaths +Edit-TextFile -Path $ScriptPaths $sw.Stop(); -if( $sw.Elapsed.TotalSeconds -lt 1 ) { - $null = Read-Host "Waiting before refreshing. Press when you're done editing ( don't forget to save ;) )..." +if( $sw.Elapsed.TotalSeconds -lt 3 ) { + Write-Host -ForegroundColor DarkGreen "When done editing, you might want to run '. Reload-MyScripts'" + return } Get-Command -ListImported Reload-MyScripts -ErrorAction SilentlyContinue |