Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Substituting grep (and other) output to open files in Vim
- X-seq: zsh-users 16021
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Jérémie Roquet <arkanosis@xxxxxxxxx>
- Subject: Re: Substituting grep (and other) output to open files in Vim
- Date: Tue, 10 May 2011 18:00:24 -0700
- Cc: zsh-users@xxxxxxx, Richard Hartmann <richih.mailinglist@xxxxxxxxx>
- 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=
- In-reply-to: <BANLkTik0-EfNso_Qu_rHZBS=6z_Zo9cs_g@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <BANLkTik+65NedRoVNJMgj9+Oma_XDmz8dA@mail.gmail.com>	<BANLkTik0-EfNso_Qu_rHZBS=6z_Zo9cs_g@mail.gmail.com>
- Sender: 4wayned@xxxxxxxxx
2011/5/10 Jérémie Roquet <arkanosis@xxxxxxxxx>
> 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..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author