#!/bin/sh # The MIT License (MIT) # # Copyright (c) 2026 pacman64 # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # dyskette [options...] # # Smaller-sized remake of the `dysk` tool, and its default output. The only # options are `-help`, and `--help`, which show this message. case "$1" in -help|--help) awk '/^# +dyskette /, /^$/ { gsub(/^# ?/, ""); print }' "$0" exit 0 ;; esac [ "$1" = '--' ] && shift df -T -H "$@" | awk ' BEGIN { style = "\x1b[38;2;204;124;0m\x1b[48;2;0;135;95m" t[0] = style " " "\x1b[0m" t[1] = style "▌ " "\x1b[0m" t[2] = style "█ " "\x1b[0m" t[3] = style "█▌ " "\x1b[0m" t[4] = style "██ " "\x1b[0m" t[5] = style "██▌ " "\x1b[0m" t[6] = style "███ " "\x1b[0m" t[7] = style "███▌ " "\x1b[0m" t[8] = style "████ " "\x1b[0m" t[9] = style "████▌" "\x1b[0m" fsw = length("filesystem") typew = length("type") usedw = length("use") usepercw = length("used") freew = length("free") sizew = length("size") } NR == 1 || $2 == "tmpfs" || $2 == "devtmpfs" { next } { n++ v = $6 gsub(/%$/, "", v) for (i = 0; v >= 20; i += 2) v -= 20 if (v >= 10) i++ bar[n] = t[i] fs[n] = $1 if (fsw < length($1)) fsw = length($1) type[n] = $2 if (typew < length($2)) typew = length($2) used[n] = $4 if (usedw < length($4)) usedw = length($4) useperc[n] = $6 if (usepercw < length($6)) usepercw = length($6) free[n] = $5 if (freew < length($5)) freew = length($5) size[n] = $3 if (sizew < length($3)) sizew = length($3) s = "" for (i = 7; i <= NF; i++) { if (i > 7) s = s " " s = s $i } mnt[n] = s } END { if (n < 1) exit fmt = "%%%ds %%%ds %%%ds %%%ds %%-5s %%%ds %%%ds %%s\n" fmt = sprintf(fmt, -fsw, -typew, -usedw, usepercw, freew, sizew) printf fmt, "filesystem", "type", "used", "use", "-", "free", "size", "mountpoint" for (i = 1; i <= n; i++) { printf fmt, fs[i], type[i], used[i], useperc[i], bar[i], free[i], size[i], mnt[i] } } '