.BR \-V , " \-\-version"
Display version information and exit.
.TP
+.BR \-w , " \-\-width " \fInumber\fP
+Specifies output width as a number of characters. The default is the number of
+the terminal columns, and if not executed on a terminal, then output width is not
+restricted at all by default. This option also forces lsblk to assume that terminal
+control characters and unsafe characters are not allowed. The expected use-case is
+for example when lsblk used by
+.BR watch (1)
+command.
+.TP
.BR \-x , " \-\-sort " \fIcolumn\fP
Sort output lines by \fIcolumn\fP. This option enables \fB\-\-list\fR output format by default.
It is possible to use the option \fI\-\-tree\fP to force tree-like output and
fputs(_(" -r, --raw use raw output format\n"), out);
fputs(_(" -s, --inverse inverse dependencies\n"), out);
fputs(_(" -t, --topology output info about topology\n"), out);
- fputs(_(" -z, --zoned print zone model\n"), out);
+ fputs(_(" -w, --width <num> specifies output width as number of characters\n"), out);
fputs(_(" -x, --sort <column> sort output by <column>\n"), out);
+ fputs(_(" -z, --zoned print zone model\n"), out);
fputs(_(" --sysroot <dir> use specified directory as system root\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(22));
int c, status = EXIT_FAILURE;
char *outarg = NULL;
size_t i;
+ unsigned int width = 0;
int force_tree = 0, has_tree_col = 0;
enum {
{ "sysroot", required_argument, NULL, OPT_SYSROOT },
{ "tree", optional_argument, NULL, 'T' },
{ "version", no_argument, NULL, 'V' },
+ { "width", required_argument, NULL, 'w' },
{ NULL, 0, NULL, 0 },
};
lsblk_init_debug();
while((c = getopt_long(argc, argv,
- "abdDzE:e:fhJlnMmo:OpPiI:rstVST::x:", longopts, NULL)) != -1) {
+ "abdDzE:e:fhJlnMmo:OpPiI:rstVST::w:x:", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
break;
errtryhelp(EXIT_FAILURE);
break;
+ case 'w':
+ width = strtou32_or_err(optarg, _("invalid output width number argument"));
+ break;
case 'x':
lsblk->flags &= ~LSBLK_TREE; /* disable the default */
lsblk->sort_id = column_name_to_id(optarg, strlen(optarg));
if (lsblk->flags & LSBLK_JSON)
scols_table_set_name(lsblk->table, "blockdevices");
+ if (width) {
+ scols_table_set_termwidth(lsblk->table, width);
+ scols_table_set_termforce(lsblk->table, SCOLS_TERMFORCE_ALWAYS);
+ }
for (i = 0; i < ncolumns; i++) {
struct colinfo *ci = get_column_info(i);