From: vinurs <haiyuan.vinurs@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-users@zsh.org
Subject: Re: problems about zsh as file manager
Date: Thu, 29 Aug 2013 21:25:28 +0800 [thread overview]
Message-ID: <CAA=69Zc5f5BPUpJdtMj=5_9GhngQN9C+9GB9wX49g2FgKPQu-Q@mail.gmail.com> (raw)
In-Reply-To: <20130829101129.1a8c610d@pwslap01u.europe.root.pri>
[-- Attachment #1: Type: text/plain, Size: 4021 bytes --]
2013/8/29 Peter Stephenson <p.stephenson@samsung.com>
> On Thu, 29 Aug 2013 09:48:19 +0800
> vinurs <haiyuan.vinurs@gmail.com> 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.
prev parent reply other threads:[~2013-08-29 13:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-29 1:48 vinurs
2013-08-29 9:11 ` Peter Stephenson
2013-08-29 13:25 ` vinurs [this message]
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='CAA=69Zc5f5BPUpJdtMj=5_9GhngQN9C+9GB9wX49g2FgKPQu-Q@mail.gmail.com' \
--to=haiyuan.vinurs@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=zsh-users@zsh.org \
/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).