From 8566ea68630163a2740dd50ede635dd2d0a59b23 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Mon, 9 Nov 2020 13:06:17 -0500 Subject: [PATCH] Better cross platform support Edit-MyScript will pause if edit is running in background (conext returning less than a second after launching editor) Test-MyModules which loads at stratup now has specific platform lists --- Edit-MyScript.ps1 | 6 ++++++ profile.d/Test-MyModules.ps1 | 12 +++++++++--- src/modules.json | 12 +++++++++--- Update-ArchOSz.ps1 => sys.Linux/Update-ArchOSz.ps1 | 0 Update-OSz.ps1 => sys.Linux/Update-OSz.ps1 | 0 .../Update-UbuntuOSz.ps1 | 0 6 files changed, 24 insertions(+), 6 deletions(-) rename Update-ArchOSz.ps1 => sys.Linux/Update-ArchOSz.ps1 (100%) rename Update-OSz.ps1 => sys.Linux/Update-OSz.ps1 (100%) rename Update-UbuntuOSz.ps1 => sys.Linux/Update-UbuntuOSz.ps1 (100%) diff --git a/Edit-MyScript.ps1 b/Edit-MyScript.ps1 index a3e57ba..50cf3b0 100644 --- a/Edit-MyScript.ps1 +++ b/Edit-MyScript.ps1 @@ -71,7 +71,13 @@ foreach( $local:p in $ScriptPaths ) { } } +$local:sw = [System.Diagnostics.Stopwatch]::StartNew(); Edit-TextFile $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 ;) )..." +} Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { . $_.Definition } diff --git a/profile.d/Test-MyModules.ps1 b/profile.d/Test-MyModules.ps1 index c8d7e9b..7ac05fc 100644 --- a/profile.d/Test-MyModules.ps1 +++ b/profile.d/Test-MyModules.ps1 @@ -1,9 +1,15 @@ -if( -not $global:MyModulesWarning ) { +param([switch]$Force) + +$local:currentSys = [SystemName]::_GetValidValues('',$true,$true); + +if( -not $global:MyModulesWarning -or $Force ) { $global:MyModulesWarning = @() } [MyConfig]::GetConfigPaths('mymodules',$false) | ForEach-Object { - $( Get-Content $_ | ConvertFrom-Json ).Modules + $local:modules = $( Get-Content $_ | ConvertFrom-Json ); + $modules.Always; + $currentSys | ForEach-Object { $modules."$_" } | Where-Object { $_} } | Where-Object { $local:m = $_ if( $( try { @@ -15,4 +21,4 @@ if( -not $global:MyModulesWarning ) { } | ForEach-Object { $global:MyModulesWarning += $_ Write-Warning "Missing module: $_" - } + } \ No newline at end of file diff --git a/src/modules.json b/src/modules.json index d375d21..4c33ec3 100644 --- a/src/modules.json +++ b/src/modules.json @@ -1,8 +1,14 @@ { - "Modules": [ - "Microsoft.PowerShell.UnixCompleters", + "Always": [ "PowerShellCookbook", "oh-my-posh", - "posh-git" + "posh-git", + "z" + ], + "Desktop": [ + ], + "Unix": [ + "Microsoft.PowerShell.UnixCompleters" ] + } diff --git a/Update-ArchOSz.ps1 b/sys.Linux/Update-ArchOSz.ps1 similarity index 100% rename from Update-ArchOSz.ps1 rename to sys.Linux/Update-ArchOSz.ps1 diff --git a/Update-OSz.ps1 b/sys.Linux/Update-OSz.ps1 similarity index 100% rename from Update-OSz.ps1 rename to sys.Linux/Update-OSz.ps1 diff --git a/Update-UbuntuOSz.ps1 b/sys.Linux/Update-UbuntuOSz.ps1 similarity index 100% rename from Update-UbuntuOSz.ps1 rename to sys.Linux/Update-UbuntuOSz.ps1