Bash shell problem on Fedora Linux

My shell environment is bash and desktop environment is LXDE. When I use the up and down button on the keyboard to view the command history on bash shell, many times part of the command from the history remains on the line. For example

/home/milhan > ssh somedomain.org
/home/milhan > 

then when I traverse the history of commands with up arrow key and come back to command prompt, the prompt looks like

/home/milhan > ssh

and when I press backspace it doesn't delete the ssh. I wasn't able to figure this out for long time. This only happens on my local machine. I ssh to other remote Unix machines where I use bash, but the same annoyance doesn't happen on those machines. I use QTerminal 0.7.1 and the default LXTerminal on my local Fedora Linux pc. Thanks.

I am guessing: On the problem box, there is a spurious non-printing character in the environment variable(s) you have defined. I do not know what you have defined, but if you have local (Ex: .bashrc) files or other "hidden" files sprinkled around you have to validate them to locate where you picked up the garbage.

Start with your home directory.

set | od -c   # check your existing variables for junk
od -c [ .filename ]   # check your initialization and setup files

Is that only for that ssh command line, or for other commands / history lines as well?

That's hard to say. The above example was just to illustrate the problem. It doesn't do it for every command and when it does, it is always 3 characters. For example, I just tested and the gre from a previous grep command was left in the command prompt.

---------- Post updated at 13:17 ---------- Previous update was at 12:23 ----------

/home/milhan > env
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.m4a=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.oga=01;36:*.opus=01;36:*.spx=01;36:*.xspf=01;36::ex=0;35:
_LXSESSION_PID=1786
XDG_CONFIG_HOME=/home/milhan/.config
PREFERRED=/usr/bin/startlxde
XDG_MENU_PREFIX=lxde-
LANG=en_US.UTF-8
HISTCONTROL=ignoredups
DISPLAY=:0.0
HOSTNAME=dellwstation
INVOCATION_ID=0d56a9429cc842f4ba3d84cef4f215bc
IMSETTINGS_INTEGRATE_DESKTOP=yes
KDEDIRS=/usr
XDG_VTNR=1
SSH_AUTH_SOCK=/tmp/ssh-jRqaTqmojPjF/agent.1786
XDG_SESSION_ID=3
USER=milhan
DESKTOP_SESSION=LXDE
IMSETTINGS_MODULE=none
PWD=/home/milhan
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/home/milhan
JOURNAL_STREAM=9:28758
SSH_AGENT_PID=1939
XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
SAL_USE_VCLPLUGIN=gtk
MAIL=/var/spool/mail/milhan
TERM=xterm
SHELL=/bin/bash
GNOME_KEYRING_CONTROL=/home/milhan/.cache/keyring-VS1SBZ
QT_IM_MODULE=xim
XMODIFIERS=@im=none
XDG_CURRENT_DESKTOP=LXDE
XDG_SEAT=seat0
SHLVL=2
COLORFGBG=15;0
LANGUAGE=
WINDOWID=0
LOGNAME=milhan
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_RUNTIME_DIR=/run/user/1000
XAUTHORITY=/home/milhan/.Xauthority
XDG_DATA_HOME=/home/milhan/.local/share
XDG_CONFIG_DIRS=/etc/xdg
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/milhan/bin:
PS1=\e[0;32m\n`whoami`@`uname -n | cut -d "." -f 1 ` :: `echo "$(date) $QUOTE"`\n`pwd` >\e[m 
HISTSIZE=
LESSOPEN=||/usr/bin/lesspipe.sh %s
GTK_IM_MODULE=gtk-im-context-simple
_=/bin/env

It's the three non-printing terminal reset characters at the end of the PS1 string that increase the char count output and thus the "length" of the prompt string that the shell takes into account. Try embedding those by enclosing in the correct codes. man bash :

1 Like

Thanks, problem fixed.