1

When I type a long command on a command-line interface. Something strange may happen in the layout. The characters I typed don't show in lines correctly. Instead, they merge into 1 line or overwrite each other. And the cursor isn't displayed in its right place. For example:
I want to type:

/home/user/example/a/b/c>$ tar --create --file example.tar e  
xample  

But it shows:

xampleuser/example/a/b/c>$ tar --create --file example.tar e  

As shown above, the second line overwrite the first line.
This problem happens in Linux on different computers. I've met similiar problems both in tty and GUI terminal emulator. It's only a problem in the display, because what I type is exactly what I enter, although it may not be what is shown.
I use American keyboard. The encoding and keymap settings are all the default ones. The keyboard is fine.
More details:

  • font: terminus-132n(tty), terminus 24pt(GUI terminal emulator)
  • OS: Linux 5.18.15-arch1-1
  • $LANG: en_US.UTF-8
  • Does this answer your question? [How to solve the issue that a Terminal screen is messed up? (usually after a resizing)](https://unix.stackexchange.com/questions/61584/how-to-solve-the-issue-that-a-terminal-screen-is-messed-up-usually-after-a-res) – don_aman Aug 02 '22 at 04:46
  • @don_aman's tip could be helpful, especially if you're using terminals with odd font sizes and window geometry. – mikem Aug 02 '22 at 04:49
  • 1
    What shell are you using? Does this still happen when changing the shell? – Philippos Aug 02 '22 at 05:36
  • Possibly related question: https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly – dr_ Aug 03 '22 at 09:13

1 Answers1

1

Try this...

Enter this command:

export PS1="$PWD>"

Then try a long command and see if the behavior changes. If it does, there's most likely a problem with the PS1 definition in your profile. When customizing PS1 try not to get too fancy, and avoid special characters and control codes if at all possible.

muru
  • 69,900
  • 13
  • 192
  • 292
mikem
  • 806
  • 3
  • 8
  • If it's `bash`, they most likely forgot to put non-printing characters between `\[` and `\]`. Or, they put escape-sequences anywhere but within `%{ ... %}` in the `zsh` shell's prompt. – Kusalananda Aug 02 '22 at 06:44
  • Agreed, but to determine that, my suggestion is to make PS1 very simple and see if the behavior changes. – mikem Aug 02 '22 at 07:11