Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why doesn't cd ignore files when you type say "cd fred*"
- X-seq: zsh-users 6837
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Why doesn't cd ignore files when you type say "cd fred*"
- Date: Thu, 04 Dec 2003 15:37:54 +0000
- In-reply-to: "zzapper"'s message of "Thu, 04 Dec 2003 14:54:35 GMT." <kohusvg6jgqkqqtbc5th8h12b61iomo1gr@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
zzapper wrote:
> Why doesn't cd ignore files when you type say "cd fred*" and there
> exists a file frederick.txt and a directory frederick ??
>
> I guess it's becauses the FNG handling fred* doesn't know that it's
> output is to be passed to cd .
It also doesn't know whether or not you want error checking.
> But can clever zsh be configued to avoid this behaviour.
>
> Could I tell cd to ignore files ending say .html,.txt etc
Use a wrapper. It's not 100% accurate in guessing what form of cd you
are using, but it will work the vast majority of the time.
cd() {
local -a dirs
local d
for d in $*; do
[[ -d $d ]] && dirs=($dirs $d)
done
if (( ${#dirs} == 1 )); then
builtin cd $dirs
else
# Assume it's something like e.g. `cd SOURCE REPLACE'
builtin cd "$@"
fi
}
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author