Fills the gaps recorded in JOB-BRIEF-FINDINGS.md for the functions converted to header-driven --help: 16 argument-less functions gain an EXIT STATUS section (check_fish_deps, claude-docs, claude-pr, cleanup, fast, fzf-update, gip, gip4, hist, limine-edit, lock, ports, screensleep, steam-dl, swapstat, tmux-clean), and 8 functions that already document ARGUMENTS gain EXIT STATUS too (lD, lsr, lss, lstree, lt, ltr, lx, qr). Not touched: gip6, ld, parur, sudo-toggle, upgrade, the JOB-BRIEF's 'missing ARGUMENTS' group. Re-checked their bodies against that claim -- none of the five take a positional argument ($argv only appears forwarded to the --help check), so an ARGUMENTS section would document something that doesn't exist. All five already have EXIT STATUS.
56 lines
1.9 KiB
Fish
56 lines
1.9 KiB
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# CATEGORY
|
|
# 07-system-and-monitoring
|
|
#
|
|
# SYNOPSIS
|
|
# swapstat
|
|
#
|
|
# DESCRIPTION
|
|
# Displays a colorized memory report showing kernel swappiness,
|
|
# zRAM compression ratio, zRAM device details (via zramctl), and
|
|
# active swap priority (via swapon).
|
|
#
|
|
# EXIT STATUS
|
|
# 0 Always
|
|
#
|
|
# EXAMPLE
|
|
# swapstat
|
|
function swapstat --description 'View colorized zRAM and swappiness status'
|
|
__fish_help_header (status current-function) $argv; and return 0
|
|
|
|
set -l swappiness (sysctl -n vm.swappiness)
|
|
set -l zdata (zramctl --bytes --noheadings --output DATA,TOTAL /dev/zram0 2>/dev/null)
|
|
|
|
echo (set_color --bold blue)"── Memory & zRAM Report ──"(set_color normal)
|
|
|
|
# Kernel & Compression Stats
|
|
if test -n "$zdata"
|
|
set -l raw (echo $zdata | awk '{print $1}')
|
|
set -l compressed (echo $zdata | awk '{print $2}')
|
|
if test "$compressed" -gt 0
|
|
set -l ratio (math -s2 "$raw / $compressed")
|
|
echo (set_color yellow)"Compression Ratio: "(set_color normal)"$ratio:1"
|
|
end
|
|
end
|
|
echo (set_color yellow)"Kernel Swappiness: "(set_color normal)"$swappiness"
|
|
echo ""
|
|
|
|
# Colorized zRAM Table
|
|
# Colors the header green and the device path (/dev/...) cyan
|
|
echo (set_color --bold --underline magenta)"zRAM Device Details"(set_color normal)
|
|
zramctl --output NAME,ALGORITHM,DISKSIZE,DATA,COMPR,TOTAL,STREAMS | sed \
|
|
-e "1s/.*/$(set_color --bold green)&$(set_color normal)/" \
|
|
-e "s|/dev/zram[0-9]|$(set_color cyan)&$(set_color normal)|"
|
|
|
|
echo ""
|
|
|
|
# Colorized Swapon Table
|
|
# Colors the header green and the device path cyan
|
|
echo (set_color --bold --underline magenta)"Active Swap Priority"(set_color normal)
|
|
swapon --show | sed \
|
|
-e "1s/.*/$(set_color --bold green)&$(set_color normal)/" \
|
|
-e "s|/dev/[^ ]*|$(set_color cyan)&$(set_color normal)|"
|
|
end
|