diff options
author | LAN-TW <lantw44@gmail.com> | 2013-03-31 03:10:39 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-03-31 03:10:39 +0800 |
commit | d180236783f876cc3c005aeacc8764df4a865b06 (patch) | |
tree | b95ff9e75070ab9f5eec83e98867768742ac1016 /bash_include | |
parent | d17e4330057ae3fd1e5112de3cec93a409e63fb4 (diff) | |
download | configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar.gz configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar.bz2 configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar.lz configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar.xz configfile-d180236783f876cc3c005aeacc8764df4a865b06.tar.zst configfile-d180236783f876cc3c005aeacc8764df4a865b06.zip |
bash_include: 自動偵測與設定終端機大小bash_include-20130331
Diffstat (limited to 'bash_include')
-rw-r--r-- | bash_include | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bash_include b/bash_include index a02fa5f..f4581fb 100644 --- a/bash_include +++ b/bash_include @@ -1147,6 +1147,24 @@ function createdir_askmode () fi } +function get_terminal_size () +{ + # ESC 7 = 儲存游標位置和屬性 + # ESC [r = 啟用全螢幕捲動 + # ESC [{row};{col}H = 移動游標 + # ESC 6n = 回報目前游標位置 + # ESC 8 = 還原游標位置和屬性 + echo -n $'\e7\e[r\e[999;999H\e[6n\e8' 1>&2 + read -s -d R getsize + echo $getsize | sed 's#..\([0-9]*\);\([0-9]*\)#export LINES=\1 COLUMNS=\2#' +} + +function set_terminal_size () +{ + eval `get_terminal_size` + stty cols $COLUMNS rows $LINES +} + ########## Help ########## alias helpf='help_function' @@ -1228,10 +1246,12 @@ function help_function () mvfile [-n] filenames ... [-- sudo_prefix ...] prehistory_backup set_console_title + set_terminal_size varset variables ... x createdir_askmode dirname x is_file_type filename type [-- sudo_prefix ...] x get_file_size filename [-- sudo_prefix ...] + x get_terminal_size x split_arguments [arguments ...] Obsolete functions are not printed. Type \`help_obsolete' to print them. |