Terminal is broken on exiting "git diff", need to run "stty sane"
gnutix opened this issue · 9 comments
Hello there,
I've just discovered your package and it looks amazing. However, every time I exit the "git diff" command, I have a broken terminal in which I don't see anything I type. The only way out of it is blind typing "reset" or "stty sane".
Any idea why that happens ? Or how I can get debug information for this issue ? I'm using an Ubuntu-based linux distro with GNOME terminal and bash.
Thanks for your help!
gnutix
Can you share your environment variables (make sure to remove any secrets)? This usually happens because the terminal cannot handle some ANSI color sequences. In the past I’ve fixed similar issues by setting the TERM variable to xterm
Sorry for the late response. Here are my environment variables before setting TERM=xterm
. We'll see if that helps!
SHELL=/bin/bash
SESSION_MANAGER=local/pop-os:@/tmp/.ICE-unix/3446,unix/pop-os:/tmp/.ICE-unix/3446
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GTK_IM_MODULE=ibus
LANGUAGE=en_US:en
LC_ADDRESS=en_US.UTF-8
LC_NAME=en_US.UTF-8
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
CINNAMON_VERSION=4.8.6
XMODIFIERS=@im=ibus
DESKTOP_SESSION=cinnamon
LC_MONETARY=en_US.UTF-8
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
PWD=/home/gnutix
LOGNAME=gnutix
XDG_SESSION_DESKTOP=cinnamon
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
XAUTHORITY=/run/user/1000/gdm/Xauthority
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
WINDOWPATH=2
HOME=/home/gnutix
USERNAME=gnutix
LC_PAPER=en_US.UTF-8
LANG=en_US.UTF-8
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=00: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:*.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:*.webp=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=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=X-Cinnamon
VTE_VERSION=6203
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/65fadc10_f917_4e5f_873a_c6d6ef1d03a2
GJS_DEBUG_OUTPUT=stderr
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
TERM=xterm-256color
LC_IDENTIFICATION=en_US.UTF-8
GTK_OVERLAY_SCROLLING=0
LESSOPEN=| /usr/bin/lesspipe %s
USER=gnutix
GNOME_TERMINAL_SERVICE=:1.112
DISPLAY=:1
SHLVL=1
LC_TELEPHONE=en_US.UTF-8
QT_IM_MODULE=ibus
LC_MEASUREMENT=en_US.UTF-8
XDG_VTNR=2
XDG_SESSION_ID=2
PAPERSIZE=letter
XDG_RUNTIME_DIR=/run/user/1000
LC_TIME=en_US.UTF-8
GTK3_MODULES=xapp-gtk3-module
XDG_DATA_DIRS=/usr/share/gnome:/usr/share/cinnamon:/home/gnutix/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
PATH=/home/gnutix/bin:/home/gnutix/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GDMSESSION=cinnamon
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
QT_FONT_DPI=144
QT_SCALE_FACTOR=2
ERGO_DOMAIN=.test
LC_NUMERIC=en_US.UTF-8
OLDPWD=/home/gnutix
_=/usr/bin/printenv
The problem still happens with TERM=xterm
. 🤷
One more thing to try: remove the COLORTERM= truecolor
line from your rc file. I'm not sure what this does exactly, but it seems unreliable based on https://gist.github.com/XVilka/8346728. If that doesn't work, the other option is to check on https://github.com/chalk/chalk. That's the library I use for terminal colors, so in theory you can reproduce this issue with just that library and file a bug.
unset COLORTERM
seems to work! 🤞 I'll close the issue in a day or two if it didn't happen again. Thanks!
Great!
"Faux espoir"; like we say in French. The issue happened again. :(
And keeps happening randomly. I think I've grown used to typing "stty sane". 🤷♂️
I am having the exact same problem so I automatized the @gnutix workaround:
git config --global core.pager "git-split-diffs --color | less -RFX; stty -F /dev/tty sane"
This also works but I don't understand why and is slower since it renders the whole diff before showing:
git config --global core.pager "git-split-diffs --color > /tmp/diffresult; less -RFX < /tmp/diffresult; rm /tmp/diffresult"