Ever faced garbled screen on a terminal, text wrapping over and screen command string messed up!
It happens because the terminal is using default row and column value (e.g. columns = 80).
The following command fixes it (tested on Docker container’s terminal)
docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -ti
How it Works?
tput
initializes or reset a terminal by providing terminal info to the shell.- From man page of
tput
:The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell
- Let’s find the type of terminal
# echo $TERM xterm
- Let’s see what’s suggested rows and columns for this terminal.
# tput cols 167 # tput lines 49
- While accessing the container terminal, we passed the number of columns and rows to COLUMNS & LINES variable.
- The terminal database is present at
/usr/share/terminfo
.
References
- https://linux.die.net/man/1/tput
- https://askubuntu.com/questions/219547/how-do-i-get-more-than-80-columns-in-command-line-mode
Written with StackEdit.