TrumanWong

stty

Modify relevant settings of the terminal command line

Supplementary instructions

stty command Modify the relevant settings of the terminal command line.

grammar

stty(option)(parameter)

Options

-a: Print all current configurations in an easy-to-read format;
-g: Print all current configurations in a stty-readable format.

Parameters

Terminal settings: Specify terminal command line setting options.

Example

On the command line, how to disable uppercase output:

stty iuclc #Open
stty -iuclc #restore

Disable lowercase output on the command line:

stty olcuc #Open
stty -olcuc #restore

Print out the number of rows and columns of the terminal:

stty size

How to change Ctrl+D:

stty eof "string"

The system default is Ctrl+D to indicate the end of the file, but through this method, it can be changed!

Display blocked:

stty -echo #Disable echo
stty echo #turn on echo

Test Methods:

stty -echo;read;stty echo;read

Ignore carriage returns:

stty igncr #Open
stty -igncr #restore

Timing input:

timeout_read()
{
     timeout=$1
     old_stty_settings=`stty -g` #save current settings
     stty -icanon min 0 time 100 #set 10seconds,not 100seconds
     eval read varname  #=read $varname
     stty "$old_stty_settings"  #recover settings
}

An easier way is to use the -t option of the read command:

read -t 10 varname