From: Christian Goeschel Ndjomouo Date: Mon, 23 Mar 2026 02:30:15 +0000 (-0400) Subject: lsblk: add column header annotations X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=08dc59804a908400831c772046e5a3f0349434dd;p=thirdparty%2Futil-linux.git lsblk: add column header annotations Signed-off-by: Christian Goeschel Ndjomouo --- diff --git a/bash-completion/lsblk b/bash-completion/lsblk index 577dcce13..3a94e3c2d 100644 --- a/bash-completion/lsblk +++ b/bash-completion/lsblk @@ -64,6 +64,7 @@ _lsblk_module() case $cur in -*) OPTS="--all + --annotate --bytes --nodeps --discard diff --git a/misc-utils/lsblk.8.adoc b/misc-utils/lsblk.8.adoc index 3c873f0f3..8510f7ae3 100644 --- a/misc-utils/lsblk.8.adoc +++ b/misc-utils/lsblk.8.adoc @@ -202,6 +202,8 @@ Reads data from a file. This method is only used if the --sysroot option is spec *none*;; Does not probe. This method always stops probing. +include::man-common/annotate.adoc[] + include::man-common/help-version.adoc[] == EXIT STATUS diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 6a8769bc7..c129c39b2 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -2347,6 +2347,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -o, --output output columns (see --list-columns)\n"), out); fputs(_(" -p, --paths print complete device path\n"), out); fputs(_(" -r, --raw use raw output format\n"), out); + fputs(_(" --annotate[=]\n" + " annotate columns with a tooltip (always|never|auto)\n"), out); fputs(_(" -s, --inverse inverse dependencies\n"), out); fputs(_(" -t, --topology output info about topology\n"), out); fputs(_(" -w, --width specifies output width as number of characters\n"), out); @@ -2413,7 +2415,7 @@ int main(int argc, char *argv[]) }; struct lsblk_devtree *tr = NULL; int c, status = EXIT_FAILURE, collist = 0; - char *outarg = NULL; + char *outarg = NULL, *annotate_opt_arg = NULL; size_t i; unsigned int width = 0; int force_tree = 0, has_tree_col = 0; @@ -2424,7 +2426,8 @@ int main(int argc, char *argv[]) OPT_COUNTER, OPT_HIGHLIGHT, OPT_PROPERTIES_BY, - OPT_HYPERLINK + OPT_HYPERLINK, + OPT_ANNOTATE, }; static const struct option longopts[] = { @@ -2468,6 +2471,7 @@ int main(int argc, char *argv[]) { "ct", required_argument, NULL, OPT_COUNTER }, { "properties-by", required_argument, NULL, OPT_PROPERTIES_BY }, { "list-columns", no_argument, NULL, 'H' }, + { "annotate", optional_argument, NULL, OPT_ANNOTATE }, { NULL, 0, NULL, 0 }, }; @@ -2689,6 +2693,9 @@ int main(int argc, char *argv[]) if (hyperlinkwanted(optarg)) lsblk->uri = xgethosturi(NULL); break; + case OPT_ANNOTATE: + annotate_opt_arg = optarg; + break; case 'H': collist = 1; break; @@ -2707,6 +2714,9 @@ int main(int argc, char *argv[]) if (force_tree) lsblk->flags |= LSBLK_TREE; + if (annotationwanted(annotate_opt_arg)) + lsblk->annotate_headers = true; + check_sysdevblock(); if (!ncolumns) { @@ -2820,6 +2830,9 @@ int main(int argc, char *argv[]) scols_column_set_uri(cl, lsblk->uri); set_column_type(ci, cl, fl); + + if (lsblk->annotate_headers && ci->help) + scols_column_refer_annotation(cl, ci->help); } if (lsblk->filter) diff --git a/misc-utils/lsblk.h b/misc-utils/lsblk.h index 90d2df1a1..d9dbacdb7 100644 --- a/misc-utils/lsblk.h +++ b/misc-utils/lsblk.h @@ -79,6 +79,7 @@ struct lsblk { bool dedup_hidden; /* deduplication column not between output columns */ bool force_tree_order; /* sort lines by parent->tree relation */ bool noempty; /* hide empty devices */ + bool annotate_headers; /* annotate column headers */ }; extern struct lsblk *lsblk; /* global handler */