=Generalize editor initialization
This commit is contained in:
parent
0a2bb25700
commit
2ce7561fb7
|
@ -5,7 +5,7 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
$global:WaitForEditor = (($WaitForEditor, 0 -ne $null)[0], 5 -ne 0)[0]
|
$global:WaitForEditor = (($WaitForEditor, -1 -ne $null)[0], 5 -ne -1)[0]
|
||||||
$PathForEditor = @()
|
$PathForEditor = @()
|
||||||
}
|
}
|
||||||
process {
|
process {
|
||||||
|
@ -15,7 +15,7 @@ process {
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
$local:editors = $env:EDITOR,'nvim','code'
|
$local:editors = $env:EDITOR,'nvim','codium','code'
|
||||||
$local:editor = $null
|
$local:editor = $null
|
||||||
foreach( $local:testEditor in $editors ) {
|
foreach( $local:testEditor in $editors ) {
|
||||||
if( $(try{Get-Command -ListImported -Type Application $testEditor -ErrorAction SilentlyContinue}catch{}) ) {
|
if( $(try{Get-Command -ListImported -Type Application $testEditor -ErrorAction SilentlyContinue}catch{}) ) {
|
||||||
|
@ -28,10 +28,10 @@ end {
|
||||||
$editor += ' -p'
|
$editor += ' -p'
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $editor -match 'code(\.exe)?"$' ) {
|
if( $EditorProcessName ) {
|
||||||
if( -not (Get-Process -Name 'code' -ErrorAction SilentlyContinue) ) {
|
if( -not (Get-Process -Name $EditorProcessName -ErrorAction SilentlyContinue) ) {
|
||||||
Invoke-ExpressionEx -sudo:$sudo "& $editor"
|
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
|
Start-Sleep -Seconds 1
|
||||||
}
|
}
|
||||||
Write-Host -ForegroundColor DarkCyan "Please wait, initializing editor..."
|
Write-Host -ForegroundColor DarkCyan "Please wait, initializing editor..."
|
||||||
|
|
Loading…
Reference in New Issue