From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4297 invoked by alias); 29 Aug 2013 09:11:43 -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: 17955 Received: (qmail 3530 invoked from network); 29 Aug 2013 09:11:35 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-b7f0a6d000007b1b-c9-521f104212e3 Date: Thu, 29 Aug 2013 10:11:29 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: problems about zsh as file manager Message-id: <20130829101129.1a8c610d@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupiluLIzCtJLcpLzFFi42I5/e/4ZV0nAfkgg3XftSx2nFzJ6MDoserg B6YAxigum5TUnMyy1CJ9uwSujC3Hp7AV3JeueP9+KnsD43fRLkZODgkBE4nFt0+zQNhiEhfu rWcDsYUEljJKzH3I1cXIBWIzSVy88hysiEVAVWLq/bmsIDabgKHE1E2zGUFsEQFRieUrNrOD 2MIC+hJ7r/xhArF5Bewlju+6AmRzcHAKBEuc+akJYgoJBEj0/LMFqeAHqr769xMTxAn2EjOv nGGE6BSU+DH5HthWZgEtic3bmlghbHmJzWveMk9gFJiFpGwWkrJZSMoWMDKvYhRNLU0uKE5K zzXUK07MLS7NS9dLzs/dxAgJvy87GBcfszrEKMDBqMTDG/FbNkiINbGsuDL3EKMEB7OSCO9b TvkgId6UxMqq1KL8+KLSnNTiQ4xMHJxSDYy2uVH7f/193uqy49Yd74SVlwQ9Hj8K29m9+5qK vlHDkbrSfwd+L57191VcTsCjlPfBr7j2q79csObrV9ubMxd6TBVg2j/9s6GyePPRT6EZXk9P X5E5KNbNrBL0fve73qK+Uw831lh7mfR9U1aY4i+4IP/bFW1hy45lswSXXfd/8V496pFCmc45 JZbijERDLeai4kQA4ZUcnR0CAAA= 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? > 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