You are not logged in.
Hello,
I want to use the following 'read-command' in a function sourced by zsh, but maybe sometimes by bash, too. It works pretty well within bash, but unfortunately it doesn't work with zsh, too.
read -i "$(sed -n "$1p" ${file})" -p "$PS1 " -e command
eval ${command}
It reads the $1'st line of a file and writes it behind the prompt. I can edit this line and finally, I can execute it with the enter button. Is there an equivalent solution for zsh?
Thanks in advance
p.s. I'm sorry for my english, it isn't my native language.
Offline
You will want to use something zle related to do this in zsh, as its read builtin looks to be rather separate from its line editor.
I hope that this will help you make progress with a zsh version:
if [[ -n $ZSH_VERSION ]]; then
command=$(sed -n "$1p" ${file})
vared -p "$PS1" command
else
read -i "$(sed -n "$1p" ${file})" -p "$PS1 " -e command
fi
eval ${command}
See also: man zshzle
Last edited by WesleyDimble (2013-03-01 14:28:55)
Offline