Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cd to a file
- X-seq: zsh-users 11442
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: cd to a file
- Date: Sun, 22 Apr 2007 20:18:18 +0200
- In-reply-to: <20070421151225.58926.qmail@xxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070416160051.GB28724@xxxxxxxxxxxxxxx> <20070421151225.58926.qmail@xxxxxxxxxxx>
Atom Smasher <atom@xxxxxxxxxxx>:
> 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...
Hm, I actually think, that my wrapper works for most (all?) possible
invocations of the 'cd' builtin.
> 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
> }
This breaks things like 'cd -2', 'cd +2' or 'cd +'.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author