Read Command : Display the prompt in color (or enable interpretation of backslash escapes)

后端 未结 4 2028
星月不相逢
星月不相逢 2020-12-09 02:33

I often use something like read -e -p \"> All good ? (y/n)\" -n 1 confirm; to ask a confirm to the user.

I\'m looking for a way to colorize the outpu

4条回答
  •  粉色の甜心
    2020-12-09 02:51

    this work for me :

        BC=$'\e[4m'
        EC=$'\e[0m'
    
        while true; do
                read -p "Do you wish to copy table from ${BC}$HOST $PORT${EC} to ${BC}$LOCAL_HOST $LOCAL_PORT${EC}? (y or n)" yn
            case $yn in
            ....
        done
    

    Results are as follows:

    more example ,see the show case ,link is :

    mysqlis

提交回复
热议问题