From: Frank Terbeck <ft@bewatermyfriend.org>
To: Dave Yost <Dave@Yost.com>
Cc: zsh-workers@zsh.org
Subject: Re: function to replace the command line text
Date: Fri, 18 Apr 2014 23:55:22 +0200 [thread overview]
Message-ID: <874n1qxpyt.fsf@ft.bewatermyfriend.org> (raw)
In-Reply-To: <CAE5DDCE-D495-4546-ACDA-8605B8644FDC@Yost.com> (Dave Yost's message of "Fri, 18 Apr 2014 12:49:57 -0700")
Dave Yost wrote:
> Is there a builtin function that replaces the command line with the
> function's output? The completion mechanism must use such a function,
> so there has to be something like that.
>
> I want to use that function to build a function I can use to run a
> demo consisting of a sequence of commands.
>
> * Make an array of strings
> * For each step of the demo
> * Type a command or a keyboard shortcut that grabs the next string
> from the array and places it on the command line
> * Hit Enter to execute the command
Here's an outline:
zsh% foo=( FOO BAR BAZ QUUZ )
zsh% j=1
zsh% FOO() { BUFFER=${foo[j++]}; CURSOR=${#BUFFER} }
zsh% zle -N FOO
zsh% bindkey '^L' FOO
Then press Ctrl-L to get (_ is the cursor position):
zsh% FOO_
Then Ctrl-L again for:
zsh% BAR_
etc... You get the idea.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
next prev parent reply other threads:[~2014-04-18 22:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-18 19:49 Dave Yost
2014-04-18 21:55 ` Frank Terbeck [this message]
2014-04-19 3:27 ` Bart Schaefer
2014-04-24 20:34 ` zsh script to run prepared shell commands for a demo Dave Yost
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=874n1qxpyt.fsf@ft.bewatermyfriend.org \
--to=ft@bewatermyfriend.org \
--cc=Dave@Yost.com \
--cc=zsh-workers@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).