stty

ターミナルコマンドラインの関連設定の変更

補足説明

sttyコマンド端末コマンドラインの関連設定を変更します。

文法

stty(オプション)(パラメータ)

オプション

-a:現在のすべての構成を読みやすく印刷する、
-g:現在のすべての構成をstty読み取り可能に印刷します。

パラメータ

端末設定:端末コマンドラインの設定オプションを指定します。

事例紹介

コマンド・ラインの下で、大文字の出力を禁止する方法:

stty iuclc オープン
stty-iuclc 回復

コマンド・ラインでの小文字の出力を禁止するには:

stty olcuc#オン
stty-olcuc#リカバリ

印刷された端末の行数と列数:

stty size

Ctrl+Dを変更する方法:

stty eof "string"

システムのデフォルトはCtrl+Dでファイルの終了を表しますが、この方法で変更できます!

マスク表示:

stty-echo#エコー禁止
stty echo#エコーを開く

テスト方法:

stty -echo;read;stty echo;read

エコー文字を無視する:

stty igncr#オープン
stty-igncr#リカバリ

タイマ入力:

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
}

より簡単な方法は、readコマンドの-t オプションを使用することです:

read -t 10 varname