From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10559 invoked from network); 19 Aug 2001 16:30:38 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 Aug 2001 16:30:38 -0000 Received: (qmail 15362 invoked by alias); 19 Aug 2001 16:30:27 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4140 Received: (qmail 15348 invoked from network); 19 Aug 2001 16:30:26 -0000 From: Bart Schaefer Message-Id: <1010819162945.ZM17258@candle.brasslantern.com> Date: Sun, 19 Aug 2001 16:29:44 +0000 In-Reply-To: <20010819161552.A2343@apple.fruitcom.com> Comments: In reply to Eric Smith "detecting a url - run browser" (Aug 19, 4:15pm) References: <20010819161552.A2343@apple.fruitcom.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Eric Smith , zsh-users@sunsite.dk Subject: Re: detecting a url - run browser MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 19, 4:15pm, Eric Smith wrote: } Subject: detecting a url - run browser } } What would I do to configure zsh to detect } $ www.foo.com or } $ http://bar.dk etc } entered at the prompt as a url and then execute: } w3m } ? You'll have to use the preexec function -- which means it'll work only at the command line, only at the PS1 prompt (not inside a function body or a loop body or a subshell or ...), and only in zsh 4.0. [*] function preexec { local cmd cmd=(${(Q)${(z)3}}) # Adjust this URL recognition test as necessary if [[ $cmd[1] == (http://*|www.*.*) ]]; then eval "function ${(q)cmd[1]} { unsetopt noglob w3m ${(q)cmd[1]}" '$* unfunction' "${(q)cmd[1]} }" setopt noglob fi } You can probably do without the noglob twaddling; I put it there just so you don't have to quote question marks and tildes (~) and so forth in the URLs, but you still have to quote ampersands (&) and semicolons. [*] Actually preexec is available as far back as 3.1.3, but the complete combination of things in my example are available only as of very recently. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net