Last active
December 2, 2025 21:24
-
-
Save ormaaj/d485b63e4c4c50c5975ab7c325a62d36 to your computer and use it in GitHub Desktop.
fstab generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| shopt -s extglob lastpipe expand_aliases | |
| typeset -Gx BASH_COMPAT=51 | |
| function fstabfmt { | |
| local -; set +m | |
| typeset x y IFS LC_CTYPE=C | |
| typeset -a fields=(source target fstype options freq passno) | |
| typeset -ia w=("${fields[@]/*/0}") | |
| { | |
| IFS=, | |
| LIBMOUNT_FORCE_MOUNT2=always findmnt --all -Csrvuno "${fields[*]}" | |
| } | tr \\n ' ' | { | |
| IFS=' ' | |
| while read -rd ' ' 'a[x = ${#a[@]}]'; do | |
| (( (y = ${#a[x]}) > w[x = x % 6] && (w[x] = y) )) | |
| done | |
| } | |
| printf -v x '%%-%ds ' "${w[@]}" | |
| printf -- "${x/%?/\\n}" "${a[@]}" | |
| } | |
| fstabfmt "$@" | |
| # vim: set ft=bash fenc=utf-8 ff=unix ts=4 sts=4 sw=4 noet : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment