PATH 추가
This commit is contained in:
1 parent
8e0e74bb33
commit
560d066de2
1 file changed
+60
-7
+60
-7
@@ -63,21 +63,70 @@ if ($tmuxCmd) {
|
|||||||
Success "tmux installed via winget"
|
Success "tmux installed via winget"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify tmux is available (may need PATH refresh)
|
# ────────────────────────────────────────────
|
||||||
|
# Verify tmux is available and add to PATH permanently if needed
|
||||||
|
# ────────────────────────────────────────────
|
||||||
|
$tmuxBin = $null
|
||||||
|
|
||||||
|
# 1) Try current PATH
|
||||||
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
||||||
if ($tmuxCmd) {
|
if ($tmuxCmd) {
|
||||||
Success "tmux is available: $($tmuxCmd.Source)"
|
$tmuxBin = $tmuxCmd.Source
|
||||||
} else {
|
}
|
||||||
# Refresh PATH for current session
|
|
||||||
|
# 2) Refresh PATH from registry (winget may have added paths)
|
||||||
|
if (-not $tmuxBin) {
|
||||||
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
||||||
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
||||||
if ($tmuxCmd) {
|
if ($tmuxCmd) {
|
||||||
Success "tmux is available: $($tmuxCmd.Source)"
|
$tmuxBin = $tmuxCmd.Source
|
||||||
} else {
|
|
||||||
Warn "tmux was not found in PATH after installation. You may need to restart your terminal."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 3) Search common locations where winget installs tmux-windows
|
||||||
|
if (-not $tmuxBin) {
|
||||||
|
$searchDirs = @(
|
||||||
|
(Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'),
|
||||||
|
(Join-Path $env:LOCALAPPDATA 'Programs\tmux-windows'),
|
||||||
|
'C:\Program Files\tmux-windows',
|
||||||
|
'C:\Program Files (x86)\tmux-windows'
|
||||||
|
)
|
||||||
|
foreach ($dir in $searchDirs) {
|
||||||
|
if (Test-Path $dir) {
|
||||||
|
$candidate = Join-Path $dir 'tmux.exe'
|
||||||
|
if (Test-Path $candidate) { $tmuxBin = $candidate; break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Recurse under WinGet/Packages for tmux
|
||||||
|
if (-not $tmuxBin -and (Test-Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages'))) {
|
||||||
|
$found = Get-ChildItem -Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages') -Recurse -Filter 'tmux.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||||
|
if ($found) { $tmuxBin = $found.FullName }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tmuxBin) {
|
||||||
|
# Add tmux's directory to PATH for this session
|
||||||
|
$tmuxDir = Split-Path $tmuxBin
|
||||||
|
if ($env:Path -notlike "*$tmuxDir*") {
|
||||||
|
$env:Path = "$tmuxDir;$env:Path"
|
||||||
|
Info "Added $tmuxDir to PATH for this session"
|
||||||
|
}
|
||||||
|
Success "tmux is available: $tmuxBin"
|
||||||
|
|
||||||
|
# Permanently add tmux's directory to user PATH if not already there
|
||||||
|
$userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User')
|
||||||
|
if ($userPath -notlike "*$tmuxDir*") {
|
||||||
|
[System.Environment]::SetEnvironmentVariable('Path', "$tmuxDir;$userPath", 'User')
|
||||||
|
Success "Added $tmuxDir to user PATH permanently (takes effect on next login)"
|
||||||
|
} else {
|
||||||
|
Info "$tmuxDir already in user PATH"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Warn "tmux was not found in PATH after installation."
|
||||||
|
Warn "Please restart your terminal or add tmux's directory to your PATH manually."
|
||||||
|
}
|
||||||
|
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
# Step 2: Deploy .tmux.conf
|
# Step 2: Deploy .tmux.conf
|
||||||
# ────────────────────────────────────────────
|
# ────────────────────────────────────────────
|
||||||
@@ -178,6 +227,10 @@ Info ""
|
|||||||
Info "=================================================="
|
Info "=================================================="
|
||||||
Success "tmux installation complete!"
|
Success "tmux installation complete!"
|
||||||
Info "=================================================="
|
Info "=================================================="
|
||||||
|
if ($tmuxBin) {
|
||||||
|
Info ""
|
||||||
|
Info "tmux binary: $tmuxBin"
|
||||||
|
}
|
||||||
Info ""
|
Info ""
|
||||||
Info "Getting started:"
|
Info "Getting started:"
|
||||||
Info " tmux - Start a new session"
|
Info " tmux - Start a new session"
|
||||||
|
|||||||
Reference in new issue
Block a user