Hacker News new | past | comments | ask | show | jobs | submit login

bit longer, but if given a file, change to its directory

    function cd() {

        if [[ ${#} -eq 0 ]]; then
            builtin cd
            return
        fi

        if [[ -f ${1} ]]; then
            builtin cd $(dirname ${1})
        else
            builtin cd ${1}
        fi

    }



Tried in cygwin and was a no-go. Tried some other concoctions in stack-overflow without success. Then I whiped this one and it worked. With a warning that will be promptly subdue to >/dev/null

function gothere {

    cd $(dirname -z `find -iname $1`)

}




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: