From 9b34662c513cfd6ba917bcadfd03dce530e8569c Mon Sep 17 00:00:00 2001 From: Jerry Chae Date: Wed, 13 May 2026 22:29:18 +0900 Subject: [PATCH] =?UTF-8?q?dua=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 34 +++++++++++ install-dua.ps1 | 153 ++++++++++++++++++++++++++++++++++++++++++++++++ install-dua.sh | 150 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 337 insertions(+) create mode 100644 install-dua.ps1 create mode 100755 install-dua.sh diff --git a/README.md b/README.md index 7365cdb..6e75388 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - [tmux](https://github.com/tmux/tmux) - 터미널 멀티플렉서 - [bottom](https://github.com/ClementTsang/bottom) - 호스트 모니터링 +- [dua](https://github.com/byron/dua-cli) - 디스크 사용량 분석기 - [lazygit](https://github.com/jesseduffield/lazygit) - Git 터미널 UI - [Docker](https://www.docker.com/) - 컨테이너 플랫폼 (Linux 자동 설치, Mac/Windows는 안내) - [ctop](https://github.com/bcicen/ctop) - 컨테이너 모니터링 @@ -28,6 +29,12 @@ curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-tmux curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-bottom.sh?ref_type=heads" | bash ``` +**dua:** + +```bash +curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-dua.sh?ref_type=heads" | bash +``` + **lazygit:** ```bash @@ -79,6 +86,12 @@ powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtoc powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-bottom.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-bottom.ps1' -OutFile $t; & $t" ``` +**dua:** + +```powershell +powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-dua.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-dua.ps1' -OutFile $t; & $t" +``` + **lazygit:** ```powershell @@ -164,6 +177,27 @@ btm | `k` | 선택한 프로세스 종료 | | `/` | 검색 | +### dua + +디스크 사용량 분석 도구입니다. 병렬 처리로 빠르게 디스크 사용량을 분석합니다. + +- **빠른 병렬 스캔** — SSD를 최대로 활용하여 디스크 사용량 즉시 표시 +- **인터랙티브 모드** — 탐색하며 불필요한 파일/디렉토리 삭제 +- **다양한 출력 형식** — 바이트, MB, GB, MiB, GiB 등 + +```bash +dua # 현재 디렉토리 사용량 +dua /path/to/dir # 특정 디렉토리 사용량 +dua i # 인터랙티브 모드 +``` + +| 단축키 | 동작 | +| ----------------- | -------------- | +| `↑` `↓` / `j` `k` | 탐색 | +| `?` | 도움말 | +| `d` | 선택 항목 삭제 | +| `q` / `Esc` | 종료 | + ### lazygit Git을 위한 터미널 UI 도구입니다. diff --git a/install-dua.ps1 b/install-dua.ps1 new file mode 100644 index 0000000..7824ab0 --- /dev/null +++ b/install-dua.ps1 @@ -0,0 +1,153 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Installs dua (Disk Usage Analyzer). + +.DESCRIPTION + Installs dua via winget (Byron.dua-cli) on Windows. + dua is a fast disk usage analyzer with interactive TUI mode. + + Supported platforms: + - Windows x64 (AMD64 / Intel 64bit) + - Windows ARM64 + + Prerequisites: + - winget (Windows Package Manager) — built into Windows 10 1709+ + +.EXAMPLE + .\install-dua.ps1 + + # One-liner install from remote (works on Windows 10+): + powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-dua.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-dua.ps1' -OutFile $t; & $t" + +.NOTES + If execution policy error occurs: + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +#> + +[CmdletBinding()] +param() + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +# Force TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1) +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +# ──────────────────────────────────────────── +# 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 } + +# ──────────────────────────────────────────── +# Step 1: Install dua +# ──────────────────────────────────────────── +Info "Installing dua (Disk Usage Analyzer)..." + +$duaCmd = Get-Command dua -ErrorAction SilentlyContinue +if ($duaCmd) { + $currentVer = & dua --version 2>$null + if (-not $currentVer) { $currentVer = "unknown" } + Info "dua 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/" + } + + winget install --id Byron.dua-cli --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null + Success "dua installed via winget" +} + +# ──────────────────────────────────────────── +# Verify dua is available and add to PATH permanently if needed +# ──────────────────────────────────────────── +$duaBin = $null + +# 1) Try current PATH +$duaCmd = Get-Command dua -ErrorAction SilentlyContinue +if ($duaCmd) { + $duaBin = $duaCmd.Source +} + +# 2) Refresh PATH from registry (winget may have added paths) +if (-not $duaBin) { + $env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + $duaCmd = Get-Command dua -ErrorAction SilentlyContinue + if ($duaCmd) { + $duaBin = $duaCmd.Source + } +} + +# 3) Search common locations where winget installs +if (-not $duaBin) { + $searchDirs = @( + (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'), + (Join-Path $env:LOCALAPPDATA 'Programs\dua-cli'), + 'C:\Program Files\dua-cli', + 'C:\Program Files (x86)\dua-cli' + ) + foreach ($dir in $searchDirs) { + if (Test-Path $dir) { + $candidate = Join-Path $dir 'dua.exe' + if (Test-Path $candidate) { $duaBin = $candidate; break } + } + } + + # Recurse under WinGet/Packages for dua + if (-not $duaBin -and (Test-Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages'))) { + $found = Get-ChildItem -Path (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages') -Recurse -Filter 'dua.exe' -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($found) { $duaBin = $found.FullName } + } +} + +if ($duaBin) { + # Add dua's directory to PATH for this session + $duaDir = Split-Path $duaBin + if ($env:Path -notlike "*$duaDir*") { + $env:Path = "$duaDir;$env:Path" + Info "Added $duaDir to PATH for this session" + } + Success "dua is available: $duaBin" + + # Permanently add dua's directory to user PATH if not already there + $userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User') + if ($userPath -notlike "*$duaDir*") { + [System.Environment]::SetEnvironmentVariable('Path', "$duaDir;$userPath", 'User') + Success "Added $duaDir to user PATH permanently (takes effect on next login)" + } else { + Info "$duaDir already in user PATH" + } +} else { + Warn "dua was not found in PATH after installation." + Warn "Please restart your terminal or add dua's directory to your PATH manually." +} + +# ──────────────────────────────────────────── +# Step 2: Post-install notes +# ──────────────────────────────────────────── +Info "" +Info "==================================================" +Success "dua installation complete!" +Info "==================================================" +if ($duaBin) { + Info "" + Info "dua binary: $duaBin" +} +Info "" +Info "IMPORTANT: Close this terminal and open a new one to use dua." +Info "PATH changes require a new terminal session to take effect." +Info "" +Info "Getting started:" +Info " dua - Show disk usage of current directory" +Info " dua /path/to/dir - Show disk usage of specific directory" +Info " dua i - Interactive mode (explore & delete)" +Info " dua --help - Show help" +Info "" +Info "Interactive mode shortcuts:" +Info " Arrow keys / h/j/k/l - Navigate" +Info " ? - Show help" +Info " d - Delete selected entry" +Info " q / Esc - Quit" \ No newline at end of file diff --git a/install-dua.sh b/install-dua.sh new file mode 100755 index 0000000..dfa421b --- /dev/null +++ b/install-dua.sh @@ -0,0 +1,150 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2086 + +# Installs dua (Disk Usage Analyzer) — https://github.com/byron/dua-cli +# +# Supported platforms: +# macOS : Apple Silicon (arm64), Intel (x86_64) — via Homebrew +# Linux : x86_64, aarch64 — via package manager or curl installer +# +# Prerequisites: +# - macOS: Homebrew (brew) — auto-installed if missing +# - Linux: curl — for curl-based installer + +set -euo pipefail + +# ──────────────────────────────────────────── +# Constants +# ──────────────────────────────────────────── +REPO="Byron/dua-cli" + +# ──────────────────────────────────────────── +# Utility functions (all stderr output) +# ──────────────────────────────────────────── +info() { echo "[INFO] $*" >&2; } +warn() { echo "[WARN] $*" >&2; } +error() { + echo "[ERROR] $*" >&2 + exit 1 +} +success() { echo "[OK] $*" >&2; } + +# ──────────────────────────────────────────── +# Ensure Homebrew is available on macOS +# ──────────────────────────────────────────── +ensure_brew() { + if command -v brew &>/dev/null; then + return 0 + fi + info "Homebrew is not installed. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [ -d /opt/homebrew/bin ]; then + export PATH="/opt/homebrew/bin:$PATH" + fi + if [ -d /usr/local/bin ]; then + export PATH="/usr/local/bin:$PATH" + fi + command -v brew &>/dev/null || error "Homebrew installation failed. Install it manually: https://brew.sh/" + success "Homebrew installed" +} + +# ──────────────────────────────────────────── +# Detect OS +# ──────────────────────────────────────────── +OS="$(uname -s)" +ARCH="$(uname -m)" + +case "$OS" in +Darwin | Linux) ;; +*) + error "Unsupported OS: $OS. This script only supports macOS and Linux." + ;; +esac + +# ──────────────────────────────────────────── +# Check required commands +# ──────────────────────────────────────────── +for cmd in curl; do + command -v "$cmd" &>/dev/null || error "'$cmd' command is required." +done + +# ──────────────────────────────────────────── +# Step 1: Install dua +# ──────────────────────────────────────────── +info "Installing dua (Disk Usage Analyzer)..." + +if command -v dua &>/dev/null; then + CURRENT_VER="$(dua --version 2>/dev/null || echo 'unknown')" + info "dua is already installed ($CURRENT_VER). Skipping installation." +else + case "$OS" in + Darwin) + ensure_brew + brew install dua-cli + success "dua installed via Homebrew" + ;; + Linux) + # Try package managers first, fall back to curl installer + if command -v apt-get &>/dev/null; then + # dua-cli is available in newer Ubuntu/Debian repos + info "Installing via apt-get..." + sudo apt-get update -y 2>/dev/null || true + if sudo apt-get install -y dua-cli 2>/dev/null; then + success "dua installed via apt-get" + else + info "dua-cli not in apt repos. Using curl installer..." + curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | + sh -s -- --git Byron/dua-cli --crate dua --target x86_64-unknown-linux-musl + success "dua installed via curl installer" + fi + elif command -v dnf &>/dev/null; then + sudo dnf install -y dua-cli + success "dua installed via dnf" + elif command -v pacman &>/dev/null; then + sudo pacman -S --noconfirm dua-cli + success "dua installed via pacman" + elif command -v zypper &>/dev/null; then + sudo zypper -n install dua-cli + success "dua installed via zypper" + else + info "No supported package manager found. Using curl installer..." + # Determine target + case "$ARCH" in + x86_64 | amd64) TARGET="x86_64-unknown-linux-musl" ;; + aarch64 | arm64) TARGET="aarch64-unknown-linux-musl" ;; + *) error "Unsupported Linux architecture: $ARCH" ;; + esac + curl -LSfs https://raw.githubusercontent.com/Byron/dua-cli/master/ci/install.sh | + sh -s -- --git Byron/dua-cli --crate dua --target "$TARGET" + success "dua installed via curl installer" + fi + ;; + esac +fi + +# Verify dua is available +if command -v dua &>/dev/null; then + success "dua is available: $(command -v dua)" +else + warn "dua was not found in PATH after installation. You may need to open a new terminal." +fi + +# ──────────────────────────────────────────── +# Step 2: Post-install notes +# ──────────────────────────────────────────── +info "" +info "==================================================" +success "dua installation complete!" +info "==================================================" +info "" +info "Getting started:" +info " dua - Show disk usage of current directory" +info " dua /path/to/dir - Show disk usage of specific directory" +info " dua i - Interactive mode (explore & delete)" +info " dua --help - Show help" +info "" +info "Interactive mode shortcuts:" +info " Arrow keys / h/j/k/l - Navigate" +info " ? - Show help" +info " d - Delete selected entry" +info " q / Esc - Quit"