NAME

cdtree-backend - Search tree for your directory

VERSION

This document describes version 0.006 of cdtree-backend (from Perl distribution App-CdUtils), released on 2022-09-30.

SYNOPSIS

To use in shell:

% cdtree() { cd `cdtree-backend "$1"`; }

Take a look at this example filesystem layout:

media/
  mv/
    en/
      a/
        acdc/
        ...
      b/
        bruno-mars/
        ...
      c/
        carly-rae-japsen/
        celine-dion/
        charlie-puth/
        ...
      d/
        demi-lovato/
        dido/
        ...
    fr/
      a/
      b/
      c/
        celine-dion/
        christophe-willem/
        ...
    it/
    ...
  music/
    en/
      a/
      b/
      c/
        celine-dion/
        ...
    fr/
      a/
      b/
      c/
        celine-dion/
        ...
      ...
    ...
 ...

Searching descendants, depth-first:

% cd /media/mv
% DEBUG=1 cdtree celine-dion
cdtree: Looking in /media/mv/en
cdtree: Looking in /media/mv/en/a
cdtree: Looking in /media/mv/en/a/acdc
...
cdtree: Looking in /media/mv/en/b
cdtree: Looking in /media/mv/en/b/bruno-mars
...
cdtree: Looking in /media/mv/en/c
cdtree: Found      /media/mv/en/c/celine-dion

Searching siblings:

% cd /media/mv/en/c/celine-dion
% DEBUG=1 cdtree charlie-puth
cdtree: Looking in /media/mv/en/c
cdtree: Found      /media/mv/en/c/charlie-puth

Searching parent's siblings:

% cd /media/mv/en/c/celine-dion
% DEBUG=1 cdtree evanescence
cdtree: Looking in /media/mv/en/c
cdtree: Looking in /media/mv/en/c/carly-rae-japsen
cdtree: Looking in /media/mv/en/c/charlie-puth
...
cdtree: Looking in /media/mv/en/a
cdtree: Looking in /media/mv/en/acdc
...
cdtree: Looking in /media/mv/en/b
cdtree: Looking in /media/mv/en/bruno-mars
...
cdtree: Looking in /media/mv/en/d
cdtree: Looking in /media/mv/en/d/demi-lovato
cdtree: Looking in /media/mv/en/d/dido
...
cdtree: Looking in /media/mv/en/e
cdtree: Found      /media/mv/en/e/evanescence

DESCRIPTION

cdtree is a command to change directory by searching your argument in descendants (depth-first), then siblings (depth-first), then parent's siblings (depth-first), and so on until it tries the root's siblings. It stops after it finds the directory. It can take a while(!) but it's convenient.

ENVIRONMENT

DEBUG => bool

If set to true, will print the directories as they are tried.

TODO

Timeouts/limits: number of seconds, number of directories searched.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-CdUtils.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-CdUtils.

SEE ALSO

cdpart-backend

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2022, 2016 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-CdUtils

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.