3 ms·
I have functions for two of these that I use all the time: # upcd foo : cd up to the nearest dir matching /foo/ upcd () { cd ${PWD/\/$1\/*/\/$1} } # dnc
by arnarbi 12y ago
I have functions for two of these that I use all the time:
# upcd foo : cd up to the nearest dir matching /foo/
upcd () { cd ${PWD/\/$1\/*/\/$1} }
# dncd foo : cd down to the first descendant matching /foo/
dncd () { cd $(find . -type d -name "$1" -print -quit) }
If you are in zsh, 'cd /foo/' also does the latter as long as there is only one descendant directory called foo