Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

第 29 章 Shell Terminal

dialog, whiptail, gdialog, kdialog and nautilus

目錄

29.1. terminal
29.1.1. resize - set TERMCAP and terminal settings to current xterm window size
29.1.2. tset, reset - terminal initialization
29.1.3. stty - change and print terminal line settings
29.2. tput
29.2.1. Change the prompt color using tput
29.3. dialog
29.3.1. --inputbox
29.4. whiptail - display dialog boxes from shell scripts
29.4.1. --msgbox
29.4.2. --infobox
29.4.3. --yesno
29.4.4. --inputbox
29.4.5. --passwordbox
29.4.6. --textbox
29.4.7. --checklist
29.4.8. --radiolist
29.4.9. --menu
29.4.10. --gauge

29.1. terminal

29.1.1. resize - set TERMCAP and terminal settings to current xterm window size

顯示終端屏幕的尺寸

$ resize
COLUMNS=151;
LINES=46;
export COLUMNS LINES;		
			

設置終端屏幕的尺寸

eval `resize`
			

29.1.2. tset, reset - terminal initialization

tset -e ^? 設置Backspace刪除前面一個字元
tset -k ^C 設置刪除一行
			

建議使用stty替代tset

29.1.3. stty - change and print terminal line settings

$ stty
speed 38400 baud; line = 0;
eol = M-^?; eol2 = M-^?; swtch = M-^?;
ixany iutf8

$ stty -a
speed 115200 baud; rows 46; columns 151; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

			
OLDCONFIG=`stty -g`      # save configuration
stty -echo               # do not display password
echo "Enter password: \c"
read PASSWD              # get the password
stty $OLDCONFIG          # restore configuration