mirror of
https://github.com/dnlbauer/dotfiles.git
synced 2026-09-10 13:35:30 +00:00
Compare commits
3 Commits
c197a6b4d3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f105143b5c | ||
|
|
2bac4dd8c4 | ||
|
|
78b0463b51 |
@@ -13,19 +13,43 @@
|
||||
# export TERM_BACKGROUND=light # or dark
|
||||
# in ~/.environment.local on that machine.
|
||||
#
|
||||
# Tune the response wait via TERM_BACKGROUND_TIMEOUT (tenths of a second).
|
||||
# Tune the per-attempt wait via TERM_BACKGROUND_TIMEOUT (tenths of a second)
|
||||
# and the number of attempts via TERM_BACKGROUND_ATTEMPTS. We poll rather than
|
||||
# do a single fixed-length read because on a freshly booted WSL instance the
|
||||
# very first terminal's OSC 11 reply can arrive well after a short window
|
||||
# closes; if we restored cooked/echo mode by then, the late reply leaks onto
|
||||
# the screen (and into the shell's input buffer) as literal text. Staying in
|
||||
# raw/no-echo mode across multiple short attempts lets a slow first reply
|
||||
# still be captured silently instead of leaking.
|
||||
|
||||
# Need a controlling terminal to talk to.
|
||||
[ -t 0 ] || { echo dark; exit 0; }
|
||||
exec 3<>/dev/tty || { echo dark; exit 0; }
|
||||
|
||||
# Raw mode with a short read timeout (min 0 time N = up to N*0.1s) so an
|
||||
# unresponsive terminal costs us at most that long.
|
||||
saved=$(stty -g <&3 2>/dev/null) || { echo dark; exit 0; }
|
||||
stty raw -echo min 0 time "${TERM_BACKGROUND_TIMEOUT:-4}" <&3 2>/dev/null
|
||||
|
||||
printf '\033]11;?\033\\' >&3 # OSC 11 query
|
||||
answer=$(dd bs=64 count=1 <&3 2>/dev/null)
|
||||
|
||||
answer=""
|
||||
attempts="${TERM_BACKGROUND_ATTEMPTS:-3}"
|
||||
i=0
|
||||
while [ "$i" -lt "$attempts" ]; do
|
||||
answer="$answer$(dd bs=64 count=1 <&3 2>/dev/null)"
|
||||
# A full "rgb:RRRR/GGGG/BBBB" reply has two '/' separators; stop as soon
|
||||
# as we have them instead of waiting out every remaining attempt.
|
||||
rest=${answer#*rgb:}
|
||||
if [ "$rest" != "$answer" ]; then
|
||||
tmp=$rest
|
||||
count=0
|
||||
while [ "$tmp" != "${tmp#*/}" ]; do
|
||||
count=$((count + 1))
|
||||
tmp=${tmp#*/}
|
||||
done
|
||||
[ "$count" -ge 2 ] && break
|
||||
fi
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
stty "$saved" <&3 2>/dev/null # restore before anything else
|
||||
exec 3>&-
|
||||
|
||||
@@ -7,6 +7,11 @@ export LANG=en_US.UTF-8
|
||||
# Prefered programs
|
||||
export EDITOR='vim'
|
||||
|
||||
# Force ssh/ssh-add to always prompt for passphrases in the terminal. On WSL,
|
||||
# DISPLAY is set (WSLg) and the ssh-askpass package is installed, so without
|
||||
# this OpenSSH prefers popping up a GUI askpass dialog instead of asking here.
|
||||
export SSH_ASKPASS_REQUIRE='never'
|
||||
|
||||
if type bat > /dev/null; then
|
||||
export MANPAGER='bat -plman'
|
||||
export PAGER='bat'
|
||||
|
||||
13
dot_zshrc
13
dot_zshrc
@@ -12,7 +12,18 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
||||
|
||||
autoload -U +X compinit && compinit # fix compdef not found
|
||||
# Load compdef immediately (needed before antidote loads plugins that call
|
||||
# it), but only do the expensive security audit + dump rebuild once a day;
|
||||
# otherwise just source the existing dump (-C).
|
||||
autoload -U +X compinit
|
||||
() {
|
||||
setopt local_options extended_glob
|
||||
if [[ -n ${HOME}/.zcompdump(#qN.mh+24) ]]; then
|
||||
compinit
|
||||
else
|
||||
compinit -C 2>/dev/null || compinit
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -f $HOME/.zshrc_local ]; then
|
||||
source $HOME/.zshrc_local
|
||||
|
||||
Reference in New Issue
Block a user