feat: lock when loading profile + improvements to terminal settings

This commit is contained in:
Stevan Freeborn
2026-07-21 16:23:48 -05:00
parent daaf89aa00
commit e8f8196fcc
2 changed files with 60 additions and 42 deletions
@@ -15,6 +15,15 @@
"command": "paste", "command": "paste",
"id": "User.paste" "id": "User.paste"
}, },
{
"command":
{
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"id": "User.splitPane.A6751878"
},
{ {
"command": "command":
{ {
@@ -30,11 +39,10 @@
{ {
"command": "command":
{ {
"action": "splitPane", "action": "moveFocus",
"split": "auto", "direction": "left"
"splitMode": "duplicate"
}, },
"id": "User.splitPane.A6751878" "id": "User.moveFocus.left"
}, },
{ {
"command": "toggleFocusMode", "command": "toggleFocusMode",
@@ -44,17 +52,17 @@
"command": "command":
{ {
"action": "moveFocus", "action": "moveFocus",
"direction": "left" "direction": "down"
}, },
"id": "User.moveFocus.left" "id": "User.moveFocus.down"
}, },
{ {
"command": "command":
{ {
"action": "moveFocus", "action": "resizePane",
"direction": "down" "direction": "right"
}, },
"id": "User.moveFocus.down" "id": "User.resizePane.right"
}, },
{ {
"command": "command":
@@ -72,14 +80,6 @@
}, },
"id": "User.splitPane.right" "id": "User.splitPane.right"
}, },
{
"command":
{
"action": "resizePane",
"direction": "right"
},
"id": "User.resizePane.right"
},
{ {
"command": "command":
{ {
@@ -88,6 +88,14 @@
}, },
"id": "User.moveFocus.right" "id": "User.moveFocus.right"
}, },
{
"command":
{
"action": "resizePane",
"direction": "down"
},
"id": "User.resizePane.down"
},
{ {
"command": "command":
{ {
@@ -100,14 +108,6 @@
"command": "closePane", "command": "closePane",
"id": "User.closePane" "id": "User.closePane"
}, },
{
"command":
{
"action": "resizePane",
"direction": "down"
},
"id": "User.resizePane.down"
},
{ {
"command": "command":
{ {
@@ -126,30 +126,30 @@
"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"keybindings": "keybindings":
[ [
{
"id": "User.copy.644BA8F2",
"keys": "ctrl+c"
},
{ {
"id": "Terminal.ToggleFocusMode", "id": "Terminal.ToggleFocusMode",
"keys": "alt+z" "keys": "alt+z"
}, },
{ {
"id": "User.paste", "id": "User.copy.644BA8F2",
"keys": "ctrl+v" "keys": "ctrl+c"
}, },
{ {
"id": "User.find", "id": "User.find",
"keys": "ctrl+shift+f" "keys": "ctrl+shift+f"
}, },
{ {
"id": "User.splitPane.A6751878", "id": "User.paste",
"keys": "alt+shift+d" "keys": "ctrl+v"
}, },
{ {
"id": "User.moveFocus.up", "id": "User.moveFocus.up",
"keys": "alt+k" "keys": "alt+k"
}, },
{
"id": "User.splitPane.A6751878",
"keys": "alt+shift+d"
},
{ {
"id": "User.moveFocus.left", "id": "User.moveFocus.left",
"keys": "alt+h" "keys": "alt+h"
@@ -231,7 +231,8 @@
"name": "PowerShell", "name": "PowerShell",
"opacity": 100, "opacity": 100,
"padding": "7", "padding": "7",
"source": "Windows.Terminal.PowershellCore" "source": "Windows.Terminal.PowershellCore",
"tabTitle": "terminal"
}, },
{ {
"colorScheme": "One Half Dark", "colorScheme": "One Half Dark",
@@ -271,6 +272,7 @@
] ]
}, },
"schemes": [], "schemes": [],
"searchWebDefaultQueryUrl": "https://www.google.com/search?q=%22%s%22",
"themes": [], "themes": [],
"useAcrylicInTabRow": true "useAcrylicInTabRow": true
} }
@@ -2,16 +2,32 @@ $CurrentDir = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $PR
$ProfileDir = Join-Path -Path $CurrentDir -ChildPath "Profile" $ProfileDir = Join-Path -Path $CurrentDir -ChildPath "Profile"
if (Test-Path -Path $ProfileDir) { if (Test-Path -Path $ProfileDir) {
$ProfileScripts = Get-ChildItem -Path $ProfileDir -Filter "*.ps1" | Sort-Object Name $mutexName = "Global\PowerShellProfileInit"
$mutex = [System.Threading.Mutex]::new($false, $mutexName)
foreach ($Script in $ProfileScripts) { $acquired = $false
try {
. $Script.FullName try {
$acquired = $mutex.WaitOne(10000)
if ($acquired) {
$ProfileScripts = Get-ChildItem -Path $ProfileDir -Filter "*.ps1" | Sort-Object Name
foreach ($Script in $ProfileScripts) {
try {
. $Script.FullName
}
catch {
Write-Warning "Failed to load profile module: $($Script.Name). Error: $($_.Exception.Message)"
}
}
} }
catch { else {
Write-Warning "Failed to load profile module: $($Script.Name). Error: $($_.Exception.Message)" Write-Warning "Profile initialization lock timed out — another terminal may be loading."
} }
} }
} else { finally {
if ($acquired) { $mutex.ReleaseMutex() }
$mutex.Dispose()
}
}
else {
Write-Warning "Profile directory not found at: $ProfileDir" Write-Warning "Profile directory not found at: $ProfileDir"
} }