Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: shell script that replaces the command line
On Jun 13, 2:34pm, Dave Yost wrote:
}
} but there must be a way to replace the current command line rather
} than setting the contents of the next one, yes?
Not from outside a widget, no. Only widget functions have access to
the current editor state.
But I'm not clear on why you need to do so? In your original example,
the "d" function would just "print -z previously-backgrounded-command"
and then exit, at which point a new prompt would appear and pop the
buffer stack so you'd have "previously-backgrounded-command" sitting
there ready to edit.
What part of the flow am I not seeing?
If what you want is for "d" to present a line for editing, wait for the
editor, and then continue execution after the editor returns, then what
you want is to call the "vared" command from "d".
example_d() {
local foo="echo this is the command to edit"
vared -e -h -p "Do your editing: " foo && eval $foo
}
There are a bunch of options to vared to manipulate the state in which
the editor starts/runs.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author