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

write a command line.



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,



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