If you use 'bash', try adding
shopt -s checkwinsize
This forces it to check how many lines and columns your terminal emulator is set to, every time it displays a new prompt. It normally does this anyways, as soon as the terminal window is resized (through the SIGWINCH signal). However, for various reasons, this signal is not always properly propagated to the shell, and it gets confused where to place the cursor in for example input that spans several lines.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds