I'm having problems with my well-known methods for generating data entry prompts:
read -p "Input something: " variabile
This causes problems when trying to use the arrow keys, it echoes the ANSI code for each step of the arrow key
read -e -p "Input something: " variable
This fixes the problem with the arrow keys, but when reaching the terminal width, text input does not continue on a new line, but on the same line, overwriting the (visually) existing input
echo -n "Input something: "; read -e variable
This apparently fixes the problems as previously described ... until I find that typing something and then pressing backspace overwrites the prompt, and also, when the input is longer, the visual rewriting appears again from the second new line of input.
So, is there a good way to create queries without the above problems?
UPDATE
, read -e -p
:
highlight=$(echo -e "\e[1;97m")
clear=$(echo -e "\e[0m")
read -e -p "Input$highlight something$clear: " variable
read ( , , ), , , .