简体   繁体   中英

Send a simulated keypress from ZLE script to terminal

Is it possible to simulate a keypress from withing zle function?

test (){
BUFFER="sudo $BUFFER"
CURSOR=$#BUFFER
<??send right-arrow keypress??>
}
zle -N test
bindkey "^f" test

I feel it would be a solution to my visual irk, where when I play with buffer and cursor position, I have remnant cursor on the original position of the cursor. I think that if I would be able to send right-arrow keypress to the terminal from within the test function, that it would remove it

在此处输入图片说明

this works with xdotool package

sudo_ (){
    BUFFER="sudo $BUFFER"
    CURSOR=$#BUFFER
    xdotool key 0xff53
}
zle -N sudo_
bindkey "^f" sudo_

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM