gnome-terminal hides ending characters of the current path's first row
I'm using Ubuntu-18.04.2's original ~/.bashrc
file and I have done no changes in any original files.
Do Ubuntu 18.04.2 users experience the problem I'm going to describe to you down below? Let me know, please.
I've noticed weird behaviors by varying either the current path's length or the gnome-terminal's width. I'll give you an example (I use the character |
to indicate the window's right border):
username@hostname:/directory/directory/directory/dire |
ory/directory/directory/directory$ |
As you can see, at the first row, Ubuntu terminal hides the string "ct" of the word "directory"; the other rows are fine. I said the string "ct" is hidden because, if I resize the window width, that reappears but other two characters are hidden. For example:
username@hostname:/directory/directory/directory/di |
ctory/directory/directory/directory$ |
This time the string "re" is hidden. The problem always occurs at the first row!
I've done some experiments and noticed different "weird" behaviors by varying either the current path's length or the window width. I can identify five cases:
-
If the current path's length is short, I might resize the window width but every row would be still fine (no hidden characters at any rows);
-
if I increase the length of a little bit (for example adding a directory), the first row's last character is hidden;
-
If I use
cd ..
command to return untill the point 1 length and resize the window enough to make the path takes more than one row, five characters are hidden (same length but different behavior); -
By varying the window width, part of the row is overwritten as in the following examples: ........
m$ rname@hostname:/directory/directory/directory/directory |
$ ername@hostname:/directory/directory/directory/directory |
In the first example, the substring "use" is deleted and the character 'm' appears out of nowhere! The second example occurs if I shorten the window width a little bit: as you can see the substring "us" is deleted. In both cases, gnome-terminal lets me write commands over that line which would be deleted as I type.
-
If I'm inside a directory with a short name such as /usr or /home, the problem doesn't occur because I can't shorten the window enough. However, If I create a long 1st-level directory (e.g. /directorydirectorydirectorydirectorydirectory), I get the following behaviors by resizing the window width:
username@hostname:/directorydirectorydirectorydirectorydirector | m$ username@hostname:/directorydirectorydirectorydirectorydirecto | $ username@hostname:/directorydirectorydirectorydirectorydirect | $ y username@hostname:/directorydirectorydirectorydirectorydirec | {square box with 0010 inside}[[00m$ username@hostname:/directorydirectorydirectorydirectorydire | $ ory username@hostname:/directorydirectorydirectorydirectorydir | y$ ory username@hostname:/directorydirectorydirectorydirectorydi | ry$ or username@hostname:/directorydirectorydirectorydirectoryd | ory$ o username@hostname:/directorydirectorydirectorydirectory | tory$
$ grep PS1 ~/.bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
$ printf '%q\n' "$PS1"
\\\[\\e\]0\;\\u@\\h:\ \\w\\a\\\]\$\{debian_chroot:+\(\$debian_chroot\)\}\\\[\\033\[01\;32m\\\]\\u@\\h\\\[\\033\[00m\\\]:\\\[\\033\[01\;34m\\\]\\w\\\[\\033\[00m\\\]\\\$\
$ printf '%q\n' "$PROMPT_COMMAND"
''
$ locale
LANG=it_IT.UTF-8
LANGUAGE=it:en_US:en
LC_CTYPE="it_IT.UTF-8"
LC_NUMERIC=it_IT.UTF-8
LC_TIME=it_IT.UTF-8
LC_COLLATE="it_IT.UTF-8"
LC_MONETARY=it_IT.UTF-8
LC_MESSAGES="it_IT.UTF-8"
LC_PAPER=it_IT.UTF-8
LC_NAME=it_IT.UTF-8
LC_ADDRESS=it_IT.UTF-8
LC_TELEPHONE=it_IT.UTF-8
LC_MEASUREMENT=it_IT.UTF-8
LC_IDENTIFICATION=it_IT.UTF-8
LC_ALL=
Solution 1:
I know this is old. I hope @John Doe, that if you solved this you would report on the solution. Here are some of my thoughts:
- I saw this behavior at one point, but I think it was with a specific application.
- There is an interaction between the TERM environment variable and the detection of the terminal size upon resizing. Use
stty size
to get the report on the width (2nd number) that the OS believes the terminal is. I suspect the width is 2 columns more than the window allows in your nominal case. Watch how this changes with resizing the window. You can also control it viastty cols 75
. If you reduce it by 2 columns and your problem is fixed, you know that it is OS confusion about the terminal width. - It might be an issue of color change pseudo characters getting confused as being actual characters. Try removing all color from your prompt PS1.
- Just to be sure gnome-terminal and the terminfo database are not corrupted, try:
apt-get install --reinstall gnome-terminal gnome-terminal-data tinfo5
. - Try different values of TERM.