foxshell/fn/-z4h-postinstall-terminfo
2025-07-04 11:48:40 -05:00

27 lines
929 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env zsh
eval "$_z4h_opt"
# Fork to avoid triggering https://www.zsh.org/mla/workers/2020/msg00588.html
(
# ${(L):-I} is ı in Turkish locale.
LC_ALL=C
local pat hex char
for pat in "[^A-Z]" "[A-Z]"; do
for hex in $Z4H_PACKAGE_DIR/[[:xdigit:]][[:xdigit:]](:t); do
printf -v char "\\x$hex"
[[ $char == $~pat ]] || continue
[[ -e ~/.terminfo/$hex ]] || zf_mkdir -p -- ~/.terminfo/$hex || return
cp -- $Z4H_PACKAGE_DIR/$hex/* ~/.terminfo/$hex/ || return
if [[ $char == [a-z] || ! ~/.terminfo/$char -ef ~/.terminfo/${(L)char}] ]]; then
[[ -e ~/.terminfo/$char ]] ||
zf_ln -s -- $hex ~/.terminfo/$char 2>/dev/null ||
zf_mkdir -p -- ~/.terminfo/$char ||
return
cp -- $Z4H_PACKAGE_DIR/$hex/* ~/.terminfo/$char/ || return
fi
zf_rm -rf -- $Z4H_PACKAGE_DIR/$hex || return
done
done
)