dtree

Програм из командне линије за исцртавање стабала
git clone https://git.sr.ht/~strahinja/dtree
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

dtree.1.in (2571B)


      1 .\" This program is licensed under the terms of GNU GPL v3 or (at your option)
      2 .\" any later version. Copyright (C) 2023-2026  Страхиња Радић.
      3 .\" See the file LICENSE for exact copyright and license details.
      4 .Dd %DATE%
      5 .Dt DTREE 1
      6 .Os
      7 .Sh NAME
      8 .Nm dtree
      9 .Nd Command line program to draw trees
     10 .Sh SYNOPSIS
     11 .Nm
     12 .Fl hVv
     13 .Pp
     14 .Nm
     15 .Oo Fl s Ar set Oc Op Ar file
     16 .Sh DESCRIPTION
     17 .Nm
     18 is a simple command line program which reads a number of lines and formats them
     19 as a tree using line drawing characters in several sets.
     20 Each input line represents one node in a tree.
     21 The number of tabs at the start of each input line determines the nesting level
     22 of that node.
     23 It is intended for the root node to have no tabs at the start.
     24 .Pp
     25 If the
     26 .Ar file
     27 is omitted,
     28 .Nm
     29 will read from stdin.
     30 Any additional arguments after
     31 .Ar file
     32 will be ignored.
     33 .
     34 .Bl -tag -width Ds
     35 .It Fl h
     36 Prints usage information.
     37 .It Fl s Ar set
     38 Selects the symbol set
     39 .Ar set .
     40 Allowed values for
     41 .Ar set
     42 are:
     43 .Cm a
     44 (ASCII set),
     45 .Cm d
     46 (double\-stroke set),
     47 and
     48 .Cm s
     49 (single\-stroke set, default).
     50 .It Fl V
     51 Prints full version information: like
     52 .Fl v ,
     53 followed by copyright notice.
     54 .It Fl v
     55 Prints version and commit date.
     56 .El
     57 .Sh EXIT STATUS
     58 .Ex -std
     59 .Sh EXAMPLES
     60 Format a tree using double-stroke box drawing characters:
     61 .
     62 .Dl "printf \(dqA\en\etB\en\et\etC\en\etD\en\(dq | dtree \-sd"
     63 .Pp
     64 .Xr tree 1
     65 replacement:
     66 .Dl "find \. \-print | sed \-E \(dqs,[^/]+/,$(printf '\et'),g\(dq | dtree"
     67 .Pp
     68 same, using ASCII characters:
     69 .Dl "find \. \-print | sed \-E \(dqs,[^/]+/,$(printf '\et'),g\(dq | dtree \-sa"
     70 .Pp
     71 poor man's
     72 .Xr findmnt 1
     73 (depends on having
     74 .Pa /proc/mounts
     75 active):
     76 .Bd -literal
     77 LC_ALL=C sort -k2 /proc/mounts |
     78 awk 'BEGIN{ pp=0 } {		# pp = previous pointer
     79 	sl = $2;
     80 	gsub("[^/]", "", sl);
     81 	slashc = length(sl);	# slash count
     82 	if ($2 != "/" &&
     83 		substr($2,0,length(prev[pp])) == prev[pp])
     84 	{
     85 		if (prev[pp] == "/" || slashc > prevsc[pp])
     86 			pp++;
     87 		for (i = 0; i < pp; i++)
     88 			printf "\et";
     89 		prev[pp] = $2;		# previous mountpoint
     90 		prevsc[pp] = slashc;	# previous slash count
     91 	}
     92 	else if ($2 != "/")
     93 	{
     94 		if (slashc < prevsc[pp] &&
     95 			substr($2,0,length(prev[pp-1])) != prev[pp-1])
     96 			pp--;
     97 		prev[pp] = $2;
     98 		prevsc[pp] = slashc;
     99 		for (i = 0; i < pp; i++)
    100 			printf "\et";
    101 	}
    102 	else
    103 	{
    104 		prev[pp] = $2;
    105 		prevsc[pp] = slashc;
    106 	}
    107 	print $2;
    108 }' |
    109 dtree
    110 .Ed
    111 .Pp
    112 On
    113 .Ox ,
    114 replace the first command in the above pipeline with
    115 .Bd -literal
    116 mount |
    117 .Ed
    118 .Pp
    119 and the parameter
    120 .Va $2
    121 with
    122 .Va $3 .
    123 .Sh SEE ALSO
    124 .Xr tree 1
    125 .Sh AUTHORS
    126 .An "Strahinya Radich" Aq sr@strahinja.org ,
    127 2023\-2026