Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: function to replace the command line text



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



Messages sorted by: Reverse Date, Date, Thread, Author