From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6235 invoked by alias); 29 Aug 2013 13:25:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17956 Received: (qmail 19263 invoked from network); 29 Aug 2013 13:25:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HK_RANDOM_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.172 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FlKhaI2ecnKUqG2cz6OhhuFAHM6mLQTL9p4Wwea1Avs=; b=0R5qHgwo32rW7tcW2O8wiXy538v7iTQRrejc1reStqmBSQrreCtgH4KOlCQWi60M26 rD8f58us1aYIvixTfkZE32IDwqPT5KXSJuUaK7BhKYvqRsaZDIgrj46xis8MNbkQmatN 4vOLNA5K0+zPPJY5IOpNw988W6y5w6csAMXx56eNWkJIRZy+SNeU8Tj6m1rGG//V2H+K leUqcu7IxhqIdyro5qXgKtU+EaKicGEfoeU+Ecg26sX5D77qLgD6dnYUOHTi/N27CKOb 382+saHaOpv42NteUo4mJV8QZ6k/SQjgGHtEql2n8kZGEYTG5iGL3tOBua1kNZsHseJO 77wA== MIME-Version: 1.0 X-Received: by 10.58.235.69 with SMTP id uk5mr3193268vec.17.1377782728213; Thu, 29 Aug 2013 06:25:28 -0700 (PDT) In-Reply-To: <20130829101129.1a8c610d@pwslap01u.europe.root.pri> References: <20130829101129.1a8c610d@pwslap01u.europe.root.pri> Date: Thu, 29 Aug 2013 21:25:28 +0800 Message-ID: Subject: Re: problems about zsh as file manager From: vinurs To: Peter Stephenson Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=047d7bd6c2c417cb9d04e5160ac9 --047d7bd6c2c417cb9d04e5160ac9 Content-Type: text/plain; charset=UTF-8 2013/8/29 Peter Stephenson > On Thu, 29 Aug 2013 09:48:19 +0800 > vinurs wrote: > > > Hi, > > I want to use zsh as my file manager, then I found mailcap and I > configured > > my .mailcap files in my $HOME, here is an example: > > > > # pdf > > application/pdf; evince %s ; > > > > Now, I can open pdf files in zsh, but I have the following questions: > > I presume you are using zsh-mime-setup to set this up? > Yes, I use zsh-mime-setup. > > > 1. when I use evince openning pdf files , it outputs many error messages, > > but the pdf can also be opened correctly; Is there a method can make the > > error message disappear, > > for example: using >/dev/null, > > I have tried this method ,but it can't work in .mailcap > > I use a shell script to start the handler and make .mailcap point at > that. Here's my simple equivalent for okular, okular_no_output. > > > #!/bin/sh > > exec okular "$@" >/dev/null 2>&1 > > > > 2. when I opened a pdf file from zsh, then if I want close this zsh, it > > shows that : > > zsh: you have running jobs. > > Is there a method can deattach it from zsh, in zsh I using ( ) to > reach > > this purpose, but It seems that this can't work in .mailcap file. > > It doesn't look like I made this configurable. You can do the tricks > you always can with job control, such as disowning the job by hand, but > there's no way of automatically removing just MIME jobs from job > control. > > It's easy to add this as an option. With the following patch, > > zstyle ':mime:*' disown true > > will make MIME handlers put into the background not subject to job > control. > > pws > > > diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo > index 06e7ed0..1c388f1 100644 > --- a/Doc/Zsh/contrib.yo > +++ b/Doc/Zsh/contrib.yo > @@ -2861,6 +2861,14 @@ question is run using the tt(eval) builtin instead > of by starting a new > tt(sh) process. This is more efficient, but may not work in the > occasional > cases where the mailcap handler uses strict POSIX syntax. > ) > +kindex(disown, MIME style) > +item(tt(disown))( > +If this boolean style is true, mailcap handlers started in the > +background will be disowned, i.e. not subject to job control within > +the parent shell. Such handlers nearly always produce their own > +windows, so the only likely harmful side effect of setting the style is > +that it becomes harder to kill jobs from within the shell. > +) > kindex(execute-as-is, MIME style) > item(tt(execute-as-is))( > This style gives a list of patterns to be matched against files > diff --git a/Functions/MIME/zsh-mime-handler > b/Functions/MIME/zsh-mime-handler > index abaf0b6..7245c20 100644 > --- a/Functions/MIME/zsh-mime-handler > +++ b/Functions/MIME/zsh-mime-handler > @@ -74,7 +74,7 @@ if [[ $suffix != *.* ]]; then > fi > suffix=${suffix#*.} > > -local handler flags no_sh no_bg arg > +local handler flags no_sh no_bg arg bg_flag="&" > integer i > local -a exec_asis hand_nonex > > @@ -89,6 +89,9 @@ zsh-mime-contexts -a $suffix execute-as-is exec_asis || > exec_asis=('*(*)' '*(/)' > zsh-mime-contexts -a $suffix handle-nonexistent hand_nonex || > hand_nonex=('[[:alpha:]]#:/*') > > +# Set to true if the job should be disowned. > +zsh-mime-contexts -t $suffix disown && bg_flag="&!" > + > local pattern > local -a files > > @@ -309,8 +312,8 @@ else > # Otherwise it's equivalent to removing the eval and all the quotes, > # including the (q) flags. > if [[ -n $stdin ]]; then > - eval cat ${(q)argv} "|" ${(q)execargs} "&" > + eval cat ${(q)argv} "|" ${(q)execargs} $bg_flag > else > - eval ${(q)execargs} "&" > + eval ${(q)execargs} $bg_flag > fi > fi > According to the tips of yours, I wrote the function in .zshrc like this: # open pdf function vinurs-pdf () { (evince $* >/dev/null 2>&1 &) } then, in .mailcap: # pdf application/pdf; vinurs-pdf %s ; Now, it works well. the function above solved the questions 1 and 2. Thanks very much. --047d7bd6c2c417cb9d04e5160ac9--