2

When I type a long command line like dddddddddddddddddddddddddddd here, the command will overwrite the last line without changing to new line.

I first use SSH to connect to the host, then docker exec -it 525d5808c4a9 bash to the docker container.

Here is the PS1 variable of the container.

root@525d5808c4a9:/home/mhtan/git/pytorch-pretrained-bert/examples# echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
dddddddddddddddddddhome/mhtan/git/pytorch-pretrained-bert/examples# dddddddddddd 

A similar question is No new line in terminal ubuntu after changing prompt style, but that does not solve my case.

Can anybody help with this?

Vimos
  • 333

1 Answers1

1

Terminal size in Docker is a known issue, and the quick fix suggested works for me:

docker exec -e COLUMNS="`tput cols`" -e LINES="`tput lines`" -ti container bash

The COLUMNS and LINES variables tell the shell and other commands what the size of the terminal is. They seem to be unset in a docker terminal, so you set them manually.

I think you can also use the $COLUMNS and $LINES variables instead of tput cols/tput lines.

docker exec -e COLUMNS="$COLUMNS" -e LINES="$LINES" -ti container bash
Olorin
  • 3,548