2 ms·
I made something similar to that. I also made a couple other scripts to help with navigating deep directory subtrees: "cdup" would jump to the specified ancest
by mtdewcmu 11y ago
I made something similar to that. I also made a couple other scripts to help with navigating deep directory subtrees:
"cdup" would jump to the specified ancestor directory of the CWD. So from /a/b/c/d/e, "cdup b" jumps to /a/b. This beats typing "cd ../../..", & it lends itself naturally to autocomplete. Writing this script is a piece of cake.
"cdto" is roughly the inverse of "cdup". It would jump to the specified descendant of the CWD, if one exists. If there is more than one possibility, it displays a choice (using `select`). So from /a, "cdto e" might jump to /a/b/c/d/e. This entails doing a recursive directory search, which can take a little bit of time, but it can save obnoxious typing in big, nasty directory trees. Writing this script is a bit trickier.
cdto also accepted a file as argument, in which case it jumped to the directory that contained that file.