From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5128 invoked by alias); 11 May 2011 01:00:33 -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: 16021 Received: (qmail 22385 invoked from network); 11 May 2011 01:00:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.160.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=0KzcWMtvVfrUYhxVySE608Unsnu7UoqfcTKtbNKJ0Ls=; b=bAl6cYv/5nEbkIF9mT2h0eUn6P5J4PruWv9RtInG9ape7dzc19fHhdKLEn0Nw8GQiy nZqtDeGg1V+jgvD4+0hA8fiQ4JAbUJuw+xP4gosVWM4M3RrbygLdw8C2c8UuLZJazV2Q MRJ0W664Jtg06FgRAS3uTI1udSCSDfiQyKK8o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=l+JSdVY7uP6q4zgROnu20alJVciC/7mARIYiUhg2XY/3fdbgVpGMz/ZK3gfXRXnAb1 E1g6ruRSt8syOX7btFTeGf862DIOyXzTzhZkzx+NmtRhWMNnhKCY0K49H4e6ckxgeMQU CkgkFv4iONRbFcZ3dZKtfCOMDFYdXRWELmumA= MIME-Version: 1.0 Sender: 4wayned@gmail.com In-Reply-To: References: Date: Tue, 10 May 2011 18:00:24 -0700 X-Google-Sender-Auth: yB9tDro-xw6eplBevkfgpwMPils Message-ID: Subject: Re: Substituting grep (and other) output to open files in Vim From: Wayne Davison To: =?UTF-8?B?SsOpcsOpbWllIFJvcXVldA==?= Cc: zsh-users@zsh.org, Richard Hartmann Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2011/5/10 J=C3=A9r=C3=A9mie Roquet > Something like > vim() { > =C2=A0if test -r $1; then > =C2=A0 =C2=A0command vim $1 > =C2=A0else > =C2=A0 =C2=A0args=3D(${(s.:.)1}) > =C2=A0 =C2=A0[[ $args[2] =3D <-> ]] && command vim $args[1] +$args[2] || = command > vim $args[1] > =C2=A0fi > } Nice. =C2=A0Let'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() { =C2=A0 =C2=A0 if test $# !=3D 1 -o -r $1; then =C2=A0 =C2=A0 =C2=A0 =C2=A0 command vim "${@}" =C2=A0 =C2=A0 else =C2=A0 =C2=A0 =C2=A0 =C2=A0 local args =C2=A0 =C2=A0 =C2=A0 =C2=A0 args=3D(${(s.:.)1}) [[ $#args =3D=3D 2 && $args[2] =3D=3D <-> ]] \ && command vim $args[1] +$args[2] \ || command vim $args[1] =C2=A0 =C2=A0 fi } ..wayne..