Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/test-shell-rc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ if command -v zsh >/dev/null 2>&1; then
(( \$+functions[_dotfiles_comp_globdots] )) && print ' hook-left' || print ' hook-gone'
")"
expect "globdots survives a later compinit; one-shot hook removes itself" "globdots hook-gone" "$actual"

# TERM fallback: a fake infocmp makes "terminfo entry known / unknown"
# independent of the terminfo database of the host running the test.
mkdir -p "$WORK/infocmp-known" "$WORK/infocmp-unknown"
printf '#!/bin/sh\nexit 0\n' > "$WORK/infocmp-known/infocmp"
printf '#!/bin/sh\nexit 1\n' > "$WORK/infocmp-unknown/infocmp"
chmod +x "$WORK/infocmp-known/infocmp" "$WORK/infocmp-unknown/infocmp"
term_after_rc() { # <fake infocmp dir> <initial TERM>
PATH="$1:$PATH" TERM="$2" zsh -f -c ". '$DOTFILES/zsh/zshrc.zsh' 2>/dev/null; print -rn -- \"\$TERM\""
}

expect "unknown ghostty terminfo falls back to xterm-256color" \
"xterm-256color" "$(term_after_rc "$WORK/infocmp-unknown" xterm-ghostty)"
expect "known ghostty terminfo leaves TERM unchanged" \
"xterm-ghostty" "$(term_after_rc "$WORK/infocmp-known" xterm-ghostty)"
expect "unknown non-ghostty terminfo leaves TERM unchanged" \
"xterm-kitty" "$(term_after_rc "$WORK/infocmp-unknown" xterm-kitty)"
expect "empty TERM defaults to xterm-256color" \
"xterm-256color" "$(term_after_rc "$WORK/infocmp-known" "")"
else
echo ">> zsh not installed - zsh tests skipped"
fi
Expand Down
6 changes: 6 additions & 0 deletions zsh/zshrc.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

export TERM=${TERM:-xterm-256color}

# Hosts without Ghostty's terminfo (e.g. over SSH) cannot resolve xterm-ghostty;
# fall back so curses programs and line editing keep working.
if [[ "$TERM" == *ghostty* ]] && ! infocmp "$TERM" >/dev/null 2>&1; then
export TERM=xterm-256color
fi

# nvim as the standard editor
if command -v nvim >/dev/null 2>&1; then
export VISUAL=nvim
Expand Down
Loading