zsh-users
 help / color / mirror / code / Atom feed
* write a command line.
@ 2012-04-13 17:15 Ray Andrews
  2012-04-13 17:55 ` Mikael Magnusson
  2012-04-14 12:44 ` Bryan Hunt
  0 siblings, 2 replies; 7+ messages in thread
From: Ray Andrews @ 2012-04-13 17:15 UTC (permalink / raw)
  To: zsh-users

Gentlemen,

Back to attempting suicide by zsh.

Just kidding, I'm sure if I could live to be 200 by then this would all 
make perfect sense.
It's awesome that you guys have some grasp of all this.

Anyway, for now I'm trying to make a script that will create but *not* 
execute a command. That is to say it  will write a string (which will be 
a command) to the command line but not press the ENTER key. Rather, when 
the script exits it will just leave the created string on the command 
line so that I can modify it as needed and *then* I  will press the 
ENTER key at my pleasure.

A guy at StackOverflow came up with this:


function hello ()
{
BUFFER=hellothere
zle end-of-line
}
zle -N hello
#bind to Alt+a:
bindkey "\ea" hello

... Which does exactly what I want when I press 'Alt+a' , but I don't 
want to bind a key, I just want to 'do it', that is to leave 
"hellothere" on the command line after my script exits.

I tried to fool around with the 'hello' function but I can't get it to 
run by itself from the command line. With 'autoload -U zle' in my .zshrc 
I get:

     zle: function definition file not found

... with my .zshrc unmodified I get:

     zle: widgets can only be called when ZLE is active

Apart from that, the closest I've come so far is to have my script echo 
the command it generates to the history file just before quitting. I can 
then use the up arrow to retrieve it, modify it as required, and then 
execute it. If there was some way of performing an 'auto up arrow' that 
would do it I think.  But I can't believe that  zsh doesn't have some 
simple way of writing some string to the prompt line and just leaving it 
there.

Regards,


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

end of thread, other threads:[~2012-04-14 23:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 17:15 write a command line Ray Andrews
2012-04-13 17:55 ` Mikael Magnusson
2012-04-14 15:43   ` Ray Andrews
2012-04-14 19:03     ` Bart Schaefer
2012-04-14 19:42       ` Ray Andrews
2012-04-14 23:08         ` Bart Schaefer
2012-04-14 12:44 ` Bryan Hunt

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