기본 터미널 너비는 80 자이지만 명령의 출력은 100 자 (터미널 너비보다 큼) 일 수 있으므로 한 줄에 엎질러 져 80자를 입력하고 다음 줄에 20자를 넣을 수 있습니다. 선. 터미널의 크기를 200 자로 조정하면 화면에 이미 표시된 모든 내용이 그대로 유지됩니다 (한 줄에 80, 다른 줄에 20). 터미널이 내용을 다시 칠하게하는 솔루션이 있는지 궁금해서 100 개 문자가 모두 한 줄에 맞을 것입니다.
현재 시스템은 Ubuntu Linux이며 bash를 사용합니다. OSX를 사용할 때 터미널의 내용을 다시 칠하고 이전 줄을 다시 정렬 할 수있는 것처럼 보이기 때문에 해결책이 있다고 생각합니다.
답변
이 질문을 제기 했으므로이 문제를 해결하는 코드 스 니펫을 발견했습니다.
RHEL5에서 테스트했으며 필요한 요구 사항을 성공적으로 해결하고 있습니다. 따라서 get 명령을 실행하면 일부 텍스트가 출력됩니다. 예를 들어 ls -al
, 마우스로 80 픽셀 이하의 창 크기를 조정하고, 화면에 충분한 공간이없는 경우 다음 줄로 줄 바꿈하거나 출력을 줄 바꿈하여 한 줄만 차지할 수 있습니다. 창문을 넓히십시오.
http://codesnippets.joyent.com/posts/show/1645 에서 찾았습니다
.
tput lines
tput cols
echo $LINES
echo $COLUMNS
stty size
stty size | awk '{print $1}' # lines
stty size | awk '{print $NF}' # columns
stty size | cut -d" " -f1 # lines
stty size | cut -d" " -f2 # columns
stty -a | awk '/rows/ {print $4}' # lines
stty -a | awk '/columns/ {print $6}' # columns
stty -a | sed -E -n -e 's/^.*[^[:digit:]]([[:digit:]]+)[[:space:]]+rows;.*$/\1/p;q;'
stty -a | sed -E -n -e 's/^.*[^[:digit:]]([[:digit:]]+)[[:space:]]+columns;.*$/\1/p;q;'
# automatically resize the Terminal window if it gets smaller than the default size
# positive integer test (including zero)
function positive_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); }
# resize the Terminal window
function sizetw() {
if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
printf "\e[8;${1};${2};t"
return 0
fi
return 1
}
# the default Terminal window size: 26 lines and 107 columns
sizetw 26 107
# automatically adjust Terminal window size
function defaultwindow() {
DEFAULTLINES=26
DEFAULTCOLUMNS=107
if [[ $(/usr/bin/tput lines) -lt $DEFAULTLINES ]] && [[ $(/usr/bin/tput cols) -lt $DEFAULTCOLUMNS ]]; then
sizetw $DEFAULTLINES $DEFAULTCOLUMNS
elif [[ $(/usr/bin/tput lines) -lt $DEFAULTLINES ]]; then
sizetw $DEFAULTLINES $(/usr/bin/tput cols)
elif [[ $(/usr/bin/tput cols) -lt $DEFAULTCOLUMNS ]]; then
sizetw $(/usr/bin/tput lines) $DEFAULTCOLUMNS
fi
return 0
}
# SIGWINCH is the window change signal
trap defaultwindow SIGWINCH
sizetw 26 70
sizetw 10 107
sizetw 4 15
좋은 이유가 있지만 OSX (현재 10.7.2에서 가장 작음)는 기본적으로 크기 조정을 지원하는 것으로 보입니다.