Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

treeify: allow showing a custom name for the root node

  • Loading branch information...
commit 2da90b6a64c2ab516194be740f9c13fb15746480 1 parent c9430de
@grawity authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 misc/treeify
View
7 misc/treeify
@@ -35,6 +35,7 @@ if ($TERM eq "dumb") {
my $tree = {};
my $maxdepth = 0;
+my $fakeroot;
my $path;
sub canonpath {
@@ -112,6 +113,8 @@ sub show {
for (@ARGV) {
if (/^-(\d+)$/) {
$maxdepth = $1;
+ } elsif (/^@(.+)$/) {
+ $fakeroot = $1;
} else {
$path = canonpath($_);
}
@@ -128,4 +131,8 @@ while ($path && $tree->{"."}) {
my $visible = $path ? {$path => walk($tree, $path)}
: $tree;
+if (defined $fakeroot) {
+ $visible = {$fakeroot => ($visible->{"."} // $visible)};
+}
+
show($visible);
Please sign in to comment.
Something went wrong with that request. Please try again.