12-27-06 12:29 PM
2006-12-27, 04:13(-05), Berk Birand:
[...]
> I had posted the following question to gnu.bash, but couldn't get an
> answer. I then found out about this newsgroup, and figured I could try it
> here.
>
> I know the subject sounds really weird, but that's the best I could
> do to summarize what I want in one line. I am looking for a way to echo
> some string to the bash prompt without actually executing it. The string
> should be displayed after PS1, and the user should be able to edit it
> using the standard command-line editing keys. Once s/he is done, pressing
> RETURN will finally send it to the shell, just like as usual. This can be
> from within a shell script or function, or even in C or Perl.
>
> Can this be done at all? I had looked at some escape sequences, but I
> couldn't find anything useful.
[...]
Don't know about bash, with zsh, you could do:
print -rz -- "$text"
Additionally you can define new /widgets/ that are zsh functions
you can write to bind actions on keys (for instance, it can also
be events on other sources of input). In those functions
$BUFFER, $LBUFFER, $RBUFFER, $CURSOR are read-write variables
that reflect the current editing buffer.
With any shells, on some systems there exist a tty ioctl (like
TIOCSTI) that allows you to write some data to the input queue
so that they arrive to the applications as if they had been
typed by the user.
--
Stéphane
[ Post a follow-up to this message ]
|