← Back to context

Comment by pimlottc

4 years ago

Regarding the bash script [0] to jump to Johnny Decimal directories, you can also use the CDPATH feature that's built into bash (and other POSIX shells, including dash and zsh) so that you can jump directly to a category using the normal `cd` command, with tab completion:

  $ CDPATH=$(find /path/to/cjd/* -maxdepth 0 -type d -print0 | xargs -0 printf "%s:")
  $ cd 34[tab]
  $ cd 34\ Events\34.[tab]
  34.18 Product Launch
  34.19 Company All-Hands
  34.20 Holiday Party
  $ cd 34\ Events\34.18[tab]
  $ cd 34\ Events\34.18\ Product\ Launch

0: https://johnnydecimal.com/concepts/working-at-the-terminal/

1: https://linux.101hacks.com/cd-command/cdpath/

Would you mind if I (eventually) put this up on the site? This is gold.

Happy to link it back to this comment or any other profile you send my way.

  • Go for it! CDPATH is an underrated tool.

    You can do a simpler version and just set

      CDPATH=/path/to/cjd
    

    but then you'd have to tab through the e.g. "30-39" index directories first.

    Or you could change the path in the find command to

      /path/to/cjd/*/*
    

    and go to the final xx.yy directories directly, but it hardly saves you any keystrokes when you use tab completition.