Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cd to a file



not nearly as elaborate as Frank Terbeck's function, but i think this 
provides the basic functionality to cd to a file without breaking 
anything. the "echo" command is very much optional...

cd() {
   ## cd to a file
   if [ 1 = "${#}" ] && [ '-' != "${1}" ] && [ \! -d "${1}" ] && [ -d "${1:h}" ]
   then
     echo "correcting \"${1}\" to \"${1:h}\"" >&2
     builtin cd "${1:h}"
   else
     builtin cd "${@}"
   fi
}


-- 
          ...atom

   ________________________
   http://atom.smasher.org/
   762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
   -------------------------------------------------

  	"We must have strong minds, ready to accept facts as they are."
  		-- President Harry Truman

  	"I don't care what the facts are."
  		-- President George H.W. Bush,  1988




Messages sorted by: Reverse Date, Date, Thread, Author