NAME

cdpart-backend - Change directory part

VERSION

This document describes version 0.001 of cdpart-backend (from Perl distribution App-CdUtils), released on 2016-09-29.

SYNOPSIS

To use in shell:

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

% cd /media/mv/en/c/celine-dion
% cdpart fr; # /media/mv/fr/c/celine-dion

DESCRIPTION

`cdpart` will try to substitute a directory element with specified argument, starting from the deepest. `cdpart` is useful if you have some branches with identical structures and you want to move to another branch quickly.

Suppose we have this directory structure:

media/
  mv/
    en/
      a/
      b/
      c/
        carly-rae-japsen/
        celine-dion/
        charlie-puth/
        ...
      ...
    fr/
      a/
      b/
      c/
        celine-dion/
        christophe-willem/
        ...
    de/
    ...
  music/
    en/
      a/
      b/
      c/
        celine-dion/
        ...
    fr/
      a/
      b/
      c/
        celine-dion/
        ...
      ...
    ...
 ...

You can see that the directories `mv` and `music` have the same structure: the first subdirectory level is language code (`en`, `fr`, ...), the second level is the first letter of artist's name (`a`, `b`, `c`, ...) and the third level is the name of the artist.

Suppose you are now in directory:

/media/mv/en/c/celine-dion

and you want to see Céline's French music videos (`/media/mv/fr/c/celine-dion`). If you use `cd`:

% cd ../../fr/c/celine-dion

which is too much to type because you are recreating the structure. With `cdpart`:

% cdpart fr

What `cdpart` will do is try the following in order:

/media/mv/en/c/fr
/media/mv/en/fr/celine-dion
/media/mv/fr/c/celine-dion

The third succeeds so it goes there. If no match is found until the topmost directory, `cdpart` will not change directory.

Another example:

% cdpart music

will eventually change the directory to `/media/music/fr/c/celine-dion`.

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.

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.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by 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.