Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
write a command line.
- X-seq: zsh-users 17003
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: write a command line.
- Date: Fri, 13 Apr 2012 10:15:39 -0700
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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