In zsh, define the following function:

cd-()
{
    local dir
    cd `dirname $1`
}

Then this:

cd- /usr/ports/www/linux-opera/Makefile

changes directory to /usr/ports/www/linux-opera/.

Trivial pleasure, but pleasure nevertheless.

comment 1

Here is a more zsh way to do it :) no more dirname cd-() { cd ${1:h} }

You also don't need the "local dir" line.

Comment by Bapt Thu Apr 5 09:30:48 2007
comment 2
Bapt: yeah, thanks, your code is definitely better.
Comment by tobez Thu Apr 5 11:51:33 2007
comment 3

Nice!

Joink directly into my .zshrc :)

Comment by seet Wed Nov 21 15:19:49 2007