From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29401 invoked from network); 8 Sep 2003 20:00:00 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Sep 2003 20:00:00 -0000 Received: (qmail 28309 invoked by alias); 8 Sep 2003 19:59:44 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6538 Received: (qmail 13656 invoked from network); 8 Sep 2003 19:18:03 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 8 Sep 2003 19:18:03 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.238.4.143] by sunsite.dk (MessageWall 1.0.8) with SMTP; 8 Sep 2003 19:18:3 -0000 Received: from elanus (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id A5AFC4B0E for ; Mon, 8 Sep 2003 21:18:02 +0200 (DFT) Received: from elanus.its.uu.se(127.0.0.1) by elanus.its.uu.se via virus-scan id s229376; Mon, 8 Sep 03 21:17:50 +0200 Received: from localhost (NL04-165-13.STUDENT.UU.SE [10.11.165.13]) by elanus.its.uu.se (Postfix) with ESMTP id 066244B0E for ; Mon, 8 Sep 2003 21:17:50 +0200 (DFT) Received: from jesper by localhost with local (Exim 4.20) id 19wRVp-0001l2-69 for zsh-users@sunsite.dk; Mon, 08 Sep 2003 21:17:21 +0200 Date: Mon, 8 Sep 2003 21:17:21 +0200 From: Jesper Holmberg To: Zsh Users Subject: Re: preexec function to work after `&&' Message-ID: <20030908191720.GR6280@strindberg.student.uu.se> Mail-Followup-To: Zsh Users References: <20030813131429.GA2413@fruitcom.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030813131429.GA2413@fruitcom.com> User-Agent: Mutt/1.5.4i * On Wed Aug 13, Eric Smith wrote: > function preexec { > local cmd > local application > cmd=(${(Q)${(z)3}}) > if [[ $cmd[1] == (https*://*|http://|www.*.*|*.(html|HTML)) ]]; then > application=w3m > elif [[ $cmd[1] == (*README*|*readme*|*.(svg|draft|conf|txt|xsl|xml|mail|csv)) ]]; then > application=vim > elif [[ $cmd[1] == *.(pdf|PDF) ]]; then > application=acroread > elif [[ $cmd[1] == *.(ps|PS) ]]; then > application=gv > elif [[ $cmd[1] == *.(gif|jpg|jpeg|tif|tiff|png) ]]; then > application=display > elif [[ $cmd[1] == *.(xls) ]]; then > application=ooffice > url=file:/// > elif [[ $cmd[1] == *.(gz|GZ) ]]; then > application=zless > elif [[ $cmd[1] == *.(doc) ]]; then > application=abiword > elif [[ $cmd[1] == *.(rtf|RTF) ]]; then > application=ted > fi > if [ $application ];then > eval "function ${(q)cmd[1]} { > unsetopt noglob > $application $url${(q)cmd[1]}" '$* > unfunction' "${(q)cmd[1]} > }" > setopt noglob > fi > I only now found the time to experiment with Eric's neat preexec function, and it's very nice. However, I'd like it to also work with tab completion, is that possible? I.e. say I have a file in my current directory called "foo.pdf". Writing "./foo.pdf" on the command line starts acroread with the file as an argument, just as I wanted, but I cannot type "./fo" and have a completion of the file name. I'm not even sure this would be desirable in the general case, as I'm normally not interested in completing regular files in the first position, but would it be possible to for example specify that files in the current directory should be completed? Or is there a better way to solve this problem that I haven't thought about? TIA, Jesper -- Jesper Holmberg |"But how can | jesper.holmberg@enst-bretagne.fr | one be warm | ENST Br, BP 832, 29285 Brest, FRANCE | alone?" |