From: Wayne Davison <wayned@users.sourceforge.net>
To: "Jérémie Roquet" <arkanosis@gmail.com>
Cc: zsh-users@zsh.org, Richard Hartmann <richih.mailinglist@gmail.com>
Subject: Re: Substituting grep (and other) output to open files in Vim
Date: Tue, 10 May 2011 18:00:24 -0700 [thread overview]
Message-ID: <BANLkTinJXkWFMiw4Y00dHQvQ6vqQ8F1Z-w@mail.gmail.com> (raw)
In-Reply-To: <BANLkTik0-EfNso_Qu_rHZBS=6z_Zo9cs_g@mail.gmail.com>
2011/5/10 Jérémie Roquet <arkanosis@gmail.com>
> Something like
> vim() {
> if test -r $1; then
> command vim $1
> else
> args=(${(s.:.)1})
> [[ $args[2] = <-> ]] && command vim $args[1] +$args[2] || command
> vim $args[1]
> fi
> }
Nice. Let's improve that so that it is possible to specify multiple
files and/or options and files (though we don't give anything but a
single arg special treatment) and also to avoid a "parameter not set"
error for folks that like to run interactively with "setopt no_unset":
vim() {
if test $# != 1 -o -r $1; then
command vim "${@}"
else
local args
args=(${(s.:.)1})
[[ $#args == 2 && $args[2] == <-> ]] \
&& command vim $args[1] +$args[2] \
|| command vim $args[1]
fi
}
..wayne..
next prev parent reply other threads:[~2011-05-11 1:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 13:46 Richard Hartmann
2011-05-10 14:12 ` Mikael Magnusson
2011-05-10 14:14 ` Jérémie Roquet
2011-05-10 18:16 ` Richard Hartmann
2011-05-11 1:00 ` Wayne Davison [this message]
2011-05-27 15:09 ` Richard Hartmann
2011-05-27 22:00 ` Wayne Davison
2011-05-28 11:51 ` Richard Hartmann
2011-05-10 15:26 ` Benjamin R. Haskell
2011-05-10 17:37 ` Mikael Magnusson
2011-05-10 18:16 ` Richard Hartmann
2011-05-10 18:58 ` Benjamin R. Haskell
2011-05-10 22:27 ` Richard Hartmann
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=BANLkTinJXkWFMiw4Y00dHQvQ6vqQ8F1Z-w@mail.gmail.com \
--to=wayned@users.sourceforge.net \
--cc=arkanosis@gmail.com \
--cc=richih.mailinglist@gmail.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).