2026-05-13 13:13:35 +09:00
|
|
|
#Requires -Version 5.1
|
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Installs tmux (terminal multiplexer) and deploys .tmux.conf.
|
|
|
|
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Installs tmux via winget (arndawg.tmux-windows) and deploys a
|
|
|
|
|
customized .tmux.conf to the current user's home directory.
|
|
|
|
|
|
|
|
|
|
Supported platforms:
|
|
|
|
|
- Windows x64 (AMD64 / Intel 64bit)
|
|
|
|
|
- Windows ARM64
|
|
|
|
|
|
|
|
|
|
Prerequisites:
|
|
|
|
|
- winget (Windows Package Manager) — built into Windows 10 1709+
|
|
|
|
|
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
.\install-tmux.ps1
|
|
|
|
|
|
|
|
|
|
# One-liner install from remote:
|
|
|
|
|
powershell -ExecutionPolicy Bypass -c "$t=\"$env:TEMP\install-tmux.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-tmux.ps1' -OutFile $t; & $t"
|
|
|
|
|
|
|
|
|
|
.NOTES
|
|
|
|
|
If execution policy error occurs:
|
|
|
|
|
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
|
param()
|
|
|
|
|
|
|
|
|
|
Set-StrictMode -Version Latest
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
# Utility functions
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan }
|
|
|
|
|
function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
|
|
|
|
|
function Success { Write-Host "[OK] $args" -ForegroundColor Green }
|
|
|
|
|
function ErrExit { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 }
|
|
|
|
|
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
# Constants
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
$ConfFile = Join-Path $env:USERPROFILE '.tmux.conf'
|
|
|
|
|
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
# Step 1: Install tmux
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
Info "Installing tmux..."
|
|
|
|
|
|
|
|
|
|
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
|
|
|
|
if ($tmuxCmd) {
|
|
|
|
|
$currentVer = & tmux -V 2>$null
|
|
|
|
|
if ($LASTEXITPR -ne 0) { $currentVer = "unknown" }
|
|
|
|
|
Info "tmux is already installed ($currentVer). Skipping installation."
|
|
|
|
|
} else {
|
|
|
|
|
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
|
|
|
|
|
ErrExit "winget is required. Install it from the Microsoft Store or https://learn.microsoft.com/en-us/windows/package-manager/winget/"
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-13 17:13:36 +09:00
|
|
|
winget install --id arndawg.tmux-windows --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null
|
2026-05-13 13:13:35 +09:00
|
|
|
Success "tmux installed via winget"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Verify tmux is available (may need PATH refresh)
|
|
|
|
|
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
|
|
|
|
if ($tmuxCmd) {
|
|
|
|
|
Success "tmux is available: $($tmuxCmd.Source)"
|
|
|
|
|
} else {
|
|
|
|
|
# Refresh PATH for current session
|
|
|
|
|
$env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
|
|
|
|
|
$tmuxCmd = Get-Command tmux -ErrorAction SilentlyContinue
|
|
|
|
|
if ($tmuxCmd) {
|
|
|
|
|
Success "tmux is available: $($tmuxCmd.Source)"
|
|
|
|
|
} else {
|
|
|
|
|
Warn "tmux was not found in PATH after installation. You may need to restart your terminal."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
# Step 2: Deploy .tmux.conf
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
if (Test-Path $ConfFile) {
|
|
|
|
|
$timestamp = Get-Date -Format 'yyyyMMddHHmmss'
|
|
|
|
|
$backup = "${ConfFile}.bak.${timestamp}"
|
|
|
|
|
Copy-Item $ConfFile $backup
|
|
|
|
|
Warn "Existing .tmux.conf found at $ConfFile"
|
|
|
|
|
Info "Backup saved to $backup"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tmuxConf = @'
|
|
|
|
|
# .tmux.conf 샘플
|
|
|
|
|
|
|
|
|
|
# Prefix key 변경 (기본은 Ctrl-b)
|
|
|
|
|
set -g prefix C-a
|
|
|
|
|
unbind C-b
|
|
|
|
|
bind C-a send-prefix
|
|
|
|
|
|
|
|
|
|
# 창 분할 단축키 변경
|
|
|
|
|
bind | split-window -h -c "#{pane_current_path}"
|
|
|
|
|
bind - split-window -v -c "#{pane_current_path}"
|
|
|
|
|
unbind '"'
|
|
|
|
|
unbind %
|
|
|
|
|
|
|
|
|
|
# 창 이동 단축키 (vim 스타일)
|
|
|
|
|
bind h select-pane -L
|
|
|
|
|
bind j select-pane -D
|
|
|
|
|
bind k select-pane -U
|
|
|
|
|
bind l select-pane -R
|
|
|
|
|
|
|
|
|
|
# 창 전환 단축키
|
|
|
|
|
bind -r C-h previous-window
|
|
|
|
|
bind -r C-l next-window
|
|
|
|
|
|
|
|
|
|
# 창 재정렬
|
|
|
|
|
bind Space next-layout
|
|
|
|
|
|
|
|
|
|
# 창 회전
|
|
|
|
|
bind o rotate-window
|
|
|
|
|
|
|
|
|
|
# 창 이름 변경
|
|
|
|
|
bind , command-prompt "rename-window %%"
|
|
|
|
|
|
|
|
|
|
# 창 닫기
|
|
|
|
|
bind & kill-window
|
|
|
|
|
|
|
|
|
|
# 세션 재시작
|
|
|
|
|
bind r source-file ~/.tmux.conf \; display "Reloaded!"
|
|
|
|
|
|
|
|
|
|
# 상태 표시줄 설정
|
|
|
|
|
set -g status-bg colour235
|
|
|
|
|
set -g status-fg colour136
|
|
|
|
|
set -g status-left-length 40
|
|
|
|
|
set -g status-right-length 40
|
|
|
|
|
set -g status-interval 5
|
|
|
|
|
set -g history-limit 10000
|
|
|
|
|
|
|
|
|
|
# 상태 표시줄 왼쪽 내용
|
|
|
|
|
set -g status-left '#[fg=green]#S #[fg=yellow]#H'
|
|
|
|
|
|
|
|
|
|
# 상태 표시줄 오른쪽 내용
|
|
|
|
|
set -g status-right '#[fg=cyan]%Y-%m-%d #[fg=green]%H:%M:%S'
|
|
|
|
|
|
|
|
|
|
# 활성 창 스타일
|
|
|
|
|
#set -g window-active-style 'fg=colour250,bg=colour232'
|
|
|
|
|
|
|
|
|
|
# 비활성 창 스타일
|
|
|
|
|
#set -g window-style 'fg=colour247,bg=colour236'
|
|
|
|
|
|
|
|
|
|
# 패널 테두리 색상
|
|
|
|
|
#set -g pane-border-fg colour238
|
|
|
|
|
#set -g pane-active-border-fg colour51
|
|
|
|
|
set-option -g pane-border-style 'fg=colour244'
|
|
|
|
|
set-option -g pane-active-border-style 'fg=colour77'
|
|
|
|
|
|
|
|
|
|
# 복사 모드에서 vi 키 바인딩 사용
|
|
|
|
|
setw -g mode-keys vi
|
|
|
|
|
|
|
|
|
|
# 마우스 지원 활성화
|
|
|
|
|
set -g mouse on
|
|
|
|
|
|
|
|
|
|
# 256색 지원
|
|
|
|
|
set -g default-terminal "screen-256color"
|
|
|
|
|
|
|
|
|
|
# for pi
|
|
|
|
|
set -g extended-keys on
|
|
|
|
|
set -g extended-keys-format csi-u
|
|
|
|
|
'@
|
|
|
|
|
|
|
|
|
|
Set-Content -Path $ConfFile -Value $tmuxConf -Encoding UTF8
|
|
|
|
|
Success ".tmux.conf deployed to $ConfFile"
|
|
|
|
|
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
# Step 3: Post-install notes
|
|
|
|
|
# ────────────────────────────────────────────
|
|
|
|
|
Info ""
|
|
|
|
|
Info "=================================================="
|
|
|
|
|
Success "tmux installation complete!"
|
|
|
|
|
Info "=================================================="
|
|
|
|
|
Info ""
|
|
|
|
|
Info "Getting started:"
|
|
|
|
|
Info " tmux - Start a new session"
|
|
|
|
|
Info " tmux new -s <name> - Start a named session"
|
|
|
|
|
Info " tmux attach -t <name> - Attach to a session"
|
|
|
|
|
Info " tmux ls - List sessions"
|
|
|
|
|
Info ""
|
|
|
|
|
Info "Key bindings (customized via .tmux.conf):"
|
|
|
|
|
Info " Ctrl-a | - Split horizontally"
|
|
|
|
|
Info " Ctrl-a - - Split vertically"
|
|
|
|
|
Info " Ctrl-a h/j/k/l - Navigate panes (vim-style)"
|
|
|
|
|
Info " Ctrl-a r - Reload .tmux.conf"
|
|
|
|
|
Info ""
|
|
|
|
|
Info "Config file: $ConfFile"
|