zsh-users
 help / color / mirror / code / Atom feed
From: Jesper Holmberg <jesper.holmberg.5791@student.uu.se>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: preexec function to work after `&&'
Date: Mon, 8 Sep 2003 21:17:21 +0200	[thread overview]
Message-ID: <20030908191720.GR6280@strindberg.student.uu.se> (raw)
In-Reply-To: <20030813131429.GA2413@fruitcom.com>

* 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<tab>" 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?"     |


  parent reply	other threads:[~2003-09-08 20:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-13 13:14 Eric Smith
2003-08-13 15:16 ` Oliver Kiddle
2003-09-08 19:17 ` Jesper Holmberg [this message]
2003-09-08 20:21   ` preexec function to work after `&&' -> tab completion for preexec Eric Smith
2003-09-10  7:51   ` preexec function to work after `&&' Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030908191720.GR6280@strindberg.student.uu.se \
    --to=jesper.holmberg.5791@student.uu.se \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).