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
}