From 2ce7561fb7d456c377bd4d76441fbdadda73b216 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Tue, 10 Aug 2021 15:50:43 +0000 Subject: [PATCH] =Generalize editor initialization --- base/Edit-TextFile.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/Edit-TextFile.ps1 b/base/Edit-TextFile.ps1 index 234a27e..6384dff 100644 --- a/base/Edit-TextFile.ps1 +++ b/base/Edit-TextFile.ps1 @@ -5,7 +5,7 @@ ) begin { - $global:WaitForEditor = (($WaitForEditor, 0 -ne $null)[0], 5 -ne 0)[0] + $global:WaitForEditor = (($WaitForEditor, -1 -ne $null)[0], 5 -ne -1)[0] $PathForEditor = @() } process { @@ -15,7 +15,7 @@ process { } end { - $local:editors = $env:EDITOR,'nvim','code' + $local:editors = $env:EDITOR,'nvim','codium','code' $local:editor = $null foreach( $local:testEditor in $editors ) { if( $(try{Get-Command -ListImported -Type Application $testEditor -ErrorAction SilentlyContinue}catch{}) ) { @@ -28,10 +28,10 @@ end { $editor += ' -p' } - if( $editor -match 'code(\.exe)?"$' ) { - if( -not (Get-Process -Name 'code' -ErrorAction SilentlyContinue) ) { + if( $EditorProcessName ) { + if( -not (Get-Process -Name $EditorProcessName -ErrorAction SilentlyContinue) ) { Invoke-ExpressionEx -sudo:$sudo "& $editor" - while( -not (Get-Process -Name 'code' -ErrorAction SilentlyContinue) ) { + while( -not (Get-Process -Name $EditorProcessName -ErrorAction SilentlyContinue) ) { Start-Sleep -Seconds 1 } Write-Host -ForegroundColor DarkCyan "Please wait, initializing editor..."