zsh-users
 help / color / mirror / code / Atom feed
* Open editor to create/edit stdin before feeding to a command
@ 2008-12-01 21:51 martin f krafft
  2008-12-01 23:46 ` Richard Hartmann
  2008-12-02  5:20 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: martin f krafft @ 2008-12-01 21:51 UTC (permalink / raw)
  To: zsh users mailing list

[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]

Hi folks,

I recently discovered edit-command-line[0] and that made me think
that zsh should really get a feature which would allow the user to
use an editor to feed data to a command's stdin, basically
a simplified here-document, e.g. with a syntax mockup:

   # opens editor on tmpfile, feeds file to wc stdin on close
~$ wc <<!

   # puts cat output into tmpfile, opens editor, feeds tmpfile to wc
   # on close
~$ cat |! wc

What do people think about this feature? Is it feasible?

0. http://www.zsh.org/mla/users/2006/msg00399.html

Cheers,

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
"by accepting this brick through your window, you accept it as is
 and agree to my disclaimer of all warranties, express or implied,
 as well as disclaimers of all liability, direct, indirect,
 consequential or incidental, that may arise from the installation
 of this brick into your building."                 -- seen on irc
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Open editor to create/edit stdin before feeding to a command
  2008-12-01 21:51 Open editor to create/edit stdin before feeding to a command martin f krafft
@ 2008-12-01 23:46 ` Richard Hartmann
  2008-12-02  5:20 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Hartmann @ 2008-12-01 23:46 UTC (permalink / raw)
  To: zsh users mailing list

On Mon, Dec 1, 2008 at 22:51, martin f krafft <madduck@madduck.net> wrote:

> What do people think about this feature?

Same as on IRC, I would love it :)


Richard


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Open editor to create/edit stdin before feeding to a command
  2008-12-01 21:51 Open editor to create/edit stdin before feeding to a command martin f krafft
  2008-12-01 23:46 ` Richard Hartmann
@ 2008-12-02  5:20 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2008-12-02  5:20 UTC (permalink / raw)
  To: zsh users mailing list

On Dec 1, 10:51pm, martin f krafft wrote:
}
} I recently discovered edit-command-line[0] and that made me think
} that zsh should really get a feature which would allow the user to
} use an editor to feed data to a command's stdin, basically
} a simplified here-document, e.g. with a syntax mockup:
} 
}    # opens editor on tmpfile, feeds file to wc stdin on close
} ~$ wc <<!

Unfortunately there's very little syntax you can use following "<<"
that would not potentially be in conflict with an existing here-
document.  In particular I've seen a number of scripts that use

something <<!
misc. text
!

(and so on with other punctuation).

However, you can get Awfully Darn Close (TM) to this already with a
couple of simple tricks.

For example:

    function edcat {
      emulate -L zsh
      if (( $# )); then
        ${VISUAL:-${EDITOR:-vi}} $* </dev/tty >&/dev/tty && cat $*
      else
        edcat =(:)
      fi
    }
    alias -g '@!'='<<(edcat)'

And then:

    $ wc @!

}    # puts cat output into tmpfile, opens editor, feeds tmpfile to wc
}    # on close
} ~$ cat |! wc

This one is trickier, requiring an explicit subshell to force the editor
to run synchronously.  However, it can use the same "edcat" function.

    alias -g @@='|( exec 3<&0 && edcat =(cat <&3) )|'

    $ print lookee here @@ wc

A lot of interesting things can be done with global aliases and sequences
of characters that are unlikely to need to appear unquoted otherwise.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-02  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-01 21:51 Open editor to create/edit stdin before feeding to a command martin f krafft
2008-12-01 23:46 ` Richard Hartmann
2008-12-02  5:20 ` Bart Schaefer

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).