简体   繁体   中英

bash inject escape sequences to read

I'm trying to do the following:

...$ left=$'\e[D'
...$ read -e -i "prompt${left}" line

I'd like to get prompt with cursor on t , but I get:

prompt^[[D

any ideas? Seems as if I cannot binding keystrokes with -i option

Just echo it.

echo -n "prompt${left}"
read -r line

On the command line, we can bind the read command to a function key:

bind '"'$(tput kf5)$'":"read -e -i prompt\n\e[D"'

You press F5 to run read

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