chris-marsh / pureline

A Pure Bash Powerline PS1 Command Prompt
MIT License
501 stars 94 forks source link

Using Control Characters resets the cursor #63

Open akd5027 opened 3 years ago

akd5027 commented 3 years ago

An addendum to the initial concern: This only seems to occur within tmux

using Ctrl+L to reset the terminal resets the cursor location back one space using Ctrl+U to clear the terminal line up to the PS1 does the same thing

akd5027 commented 3 years ago

Has occurred while jumping between panes as well in tmux

chris-marsh commented 3 years ago

I use tmux on all my systems and do not see this. can you post the results of env ?

akd5027 commented 3 years ago

Let me hop back in, sure. I will say that I had edited the battery segment to only show the percentage if it was not '100' and the problem totally went away. I'm wondering if reading the battery file might have a character that wasn't ignored by the PS1 or something?. Github wasn't letting me upload pictures otherwise I'd upload a photo to support. I may use another browser and try again as well. I'll go grab env now.

akd5027 commented 3 years ago

This is on Cent7 env:

XDG_VTNR=1
XDG_SESSION_ID=2
SSH_AGENT_PID=2661
TERM_PROGRAM=tmux
HOSTNAME=test-dev
IMSETTINGS_INTEGRATE_DESKTOP=yes
XDG_MENU_PREFIX=gnome-
VTE_VERSION=5204
TERM=screen-256color
SHELL=/bin/bash
HISTSIZE=1000
TERM_PROGRAM_VERSION=next-3.3
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/7fbe1b3a_4b08_4acc_884c_697da3874a11
IMSETTINGS_MODULE=none
USER=testdev
LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
DESKTOP_AUTOSTART_ID=1027a24df339e12a00162083640947469900000024940007
GNOME_TERMINAL_SERVICE=:1.114
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
USERNAME=testdev
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2494,unix/unix:/tmp/.ICE-unix/2494
TMUX=/tmp/tmux-1000/default,7183,0
GNOME_SHELL_SESSION_MODE=classic
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/testdev/.local/bin:/home/testdev/bin:/home/testdev/.bin:/home/testdev/.bin:/home/testdev/.local/bin:/home/testdev/bin
MAIL=/var/spool/mail/testdev
DESKTOP_SESSION=gnome-classic
QT_IM_MODULE=ibus
XDG_SESSION_TYPE=x11
PWD=/home/testdev
XMODIFIERS=@im=ibus
LANG=en_US.UTF-8
GDM_LANG=en_US.UTF-8
TMUX_PANE=%3
GDMSESSION=gnome-classic
HISTCONTROL=ignoredups
XDG_SEAT=seat0
SHLVL=3
HOME=/home/testdev
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
XDG_SESSION_DESKTOP=gnome-classic
LOGNAME=testdev
VISUAL=/usr/bin/vim
XDG_DATA_DIRS=/home/testdev/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-g50rniu9Q0,guid=b783c1c58ab3c2bb45f6273c609c0038
LESSOPEN=||/usr/bin/lesspipe.sh %s
WINDOWPATH=1
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME
XAUTHORITY=/run/gdm/auth-for-testdev-Et6DMM/database
COLORTERM=truecolor
_=/usr/bin/env
akd5027 commented 3 years ago

Ah, success. Emailed the photos to my other pc and uploaded.... weird:

Bad cursor reset as root RootBad

Typical Behavior Good

Bad cursor reset as typical user Bad

akd5027 commented 3 years ago

Obviously I reinserted the battery segment to reintroduce the issue..

akd5027 commented 3 years ago

EDIT --- I got my charge/discharge symbols reversed, Fixed them in this edit

After poking more, it appears the problem is the battery DIScharging symbol. The charging symbol gives me no grief in tmux, but the discharging symbol does it.

When this issue occurs, there are characters in the terminal that do not actually appear, making the commands incorrect by a character, painful for syntactically dense commands like sed and such...

akd5027 commented 3 years ago

To complete my current situation here's my battery segment

    if [ "$status" == "Discharging" ]; then
        # Disabled for now due to PS1 oddities in tmux
        : #content="${PL_SYMBOLS[battery_discharging]} "
    else
        content="${PL_SYMBOLS[battery_charging]}"
    fi

    if [ "$cap" != "100" ]; then
        content="$content$cap%"

        PS1+="$(segment_end "$fg_color" "$bg_color")"
        PS1+="$(segment_content "$fg_color" "$bg_color" " $content ")"
        __last_color="$bg_color"
    fi

Perhaps later I can look more into what the discharging character really is and how it might affect the PS1...

Were you able to see this issue as well?

chris-marsh commented 3 years ago

I see you have managed to track down the problem to your battery discharge symbol?I haven't been able to recreate the problem as I use the default symbols.

Looks like this isn't really a PureLine problem, but I'll leave the issue open to see if we can find a way to solve it.