From d54c1c5808d489c55f775302d4996e8792165246 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 12 Jul 2024 01:31:02 -0700 Subject: [PATCH] don't reset terminal charset on alacritty (fixes glitch) --- home/bashrc | 3 ++- home/zshrc | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/home/bashrc b/home/bashrc index 2d77562..5a725bb 100644 --- a/home/bashrc +++ b/home/bashrc @@ -22,7 +22,7 @@ _temporary_scope_() { local USASCII="B" SPECIAL="0" # charsets: sane default & line drawing local DECTCEM="25" local DECSET="h" SGR="m" # final characters of a command sequence - local sanity="$ESC$G0$USASCII$SI$CSI?$DECTCEM$DECSET" + local sanity="$CSI?$DECTCEM$DECSET" local color1="$CSI;--$SGR" color2="$CSI--;97$SGR" reset="$hide$CSI$SGR$show" local line1="$hide$title$sanity$color1$show $reset" local line2="$hide$color2$show$prompt$reset " @@ -31,6 +31,7 @@ _temporary_scope_() { if [ "$t" = xterm ] || [ "$t" = screen ] || [ "$t" = tmux ]; then [ "$t" = tmux ] && title="$cwd" || title="$host: $cwd" title="${OSC}2;$title$BEL" + sanity="$ESC$G0$USASCII$SI$sanity" fi PROMPT_COMMAND="[ \$? = 0 ] && PS1=\$'$ret_okay' || PS1=\$'$ret_fail'" }; _temporary_scope_; unset -f _temporary_scope_ diff --git a/home/zshrc b/home/zshrc index 8a224a3..24011d3 100644 --- a/home/zshrc +++ b/home/zshrc @@ -224,22 +224,6 @@ alias sc="~/sh/sc" # only runs in bash (for now), so be explicit with path function { # initialize prompts. - local t="${TERM%%-*}" - if [ "$t" = xterm ] || [ "$t" = screen ] || [ "$t" = tmux ]; then - # set window title - if [ "$t" = tmux ]; then - # don't include host, tmux prepends it - precmd() { print -Pn "\e]2;%~\a" } - else - precmd() { print -Pn "\e]2;%M: %~\a" } - fi - else - # act dumb - precmd() {} - PROMPT="%# " - return - fi - # zsh adds a % symbol to newline-less output, so my bash prompt is overkill # NOTE: i've started hardcoding escapes instead of relying on zsh # because detecting terminal features is too troublesome. @@ -259,6 +243,24 @@ function { (sabotage) good=45;; # magenta esac + local t="${TERM%%-*}" + if [ "$t" = xterm ] || [ "$t" = screen ] || [ "$t" = tmux ]; then + # set window title + if [ "$t" = tmux ] # don't include host, tmux prepends it + then precmd() { print -Pn "\e]2;%~\a" } + else precmd() { print -Pn "\e]2;%M: %~\a" } + fi + elif [ "$t" = alacritty ]; then + # Alacritty-v0.13.2-portable.exe -t "MinGW x64" -e "usr/bin/env" PATH="/usr/local/sbin:/usr/local/bin:/usr/bin" MSYSTEM=MINGW64 TERM=alacritty shelly + precmd() {} + chset= # displays as U+263C for some reason + else + # act dumb + precmd() {} + PROMPT="%# " + return + fi + PROMPT="%{$chset$curse$reset$s%(?.$good.$bad);97$e%}%#%{$reset%} " }