News for hackers. Stuff that matters.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by kleiba on Thursday March 26, 2026 @12:10PM (#47532280)
Just recently, I came up with this in my .bashrc, basically a "deep cd" command:

    dcd() {
        # If no argument is given, do nothing
        [ -z "$1" ] && return

        # Find the first matching directory under the current directory
        local dir
        dir=$(find . -type d -path "*$1*" -print -quit 2>/dev/null)

        # If a directory was found, cd into it
        [ -n "$dir" ] && cd "$dir"
    }
I thought this would be way too slow for actual use, but I've come to love it.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by cipritom on Thursday March 26, 2026 @12:27PM (#47532516)
you should look into autojump which has `jc` (jump child), or other similar flavours of "smart cd" (z, fzf, etc)
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by kleiba on Thursday March 26, 2026 @01:47PM (#47533490)
Thanks, but I like that this is just a small, simple bash function without the need to install 3rd-party software.