zsh: prevent tput errors when $TERM is not set

When running a command via SSH without allocating a pseudo terminal,
for example, $TERM is not set, causing `tput` to freak out about not
knowing the terminal type.

So, we suppress the customization of man pages when $TERM is not set, in
which case we wouldn't have needed it anyway, as we don't even have a
terminal to type `man` :).
This commit is contained in:
Fernando Schauenburg 2021-11-03 07:44:15 +00:00
parent e3c0bd323b
commit 42d84a2e12

View file

@ -20,7 +20,10 @@ export PAGER=less
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py" export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py"
export ZDOTDIR="$XDG_CONFIG_HOME/zsh" export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
# Make man pages pretty # Make man pages pretty, but only if $TERM is set because otherwise `tput`
# would report errors (e.g., when running a command via SSH without allocating
# a pty $TERM is not set).
[ -n "$TERM" ] && {
rst="$(tput sgr0)" rst="$(tput sgr0)"
export LESS_TERMCAP_md="$(printf '%s\n' 'setaf 3' | tput -S)" export LESS_TERMCAP_md="$(printf '%s\n' 'setaf 3' | tput -S)"
export LESS_TERMCAP_mb="$LESS_TERMCAP_md" export LESS_TERMCAP_mb="$LESS_TERMCAP_md"
@ -31,6 +34,7 @@ export LESS_TERMCAP_so="$(printf '%s\n' 'setaf 4' 'setab 0' | tput -S)"
export LESS_TERMCAP_se="$rst" export LESS_TERMCAP_se="$rst"
export GROFF_NO_SGR=1 export GROFF_NO_SGR=1
unset rst unset rst
}
# Prevent path_helper from messing with the PATH when starting tmux. # Prevent path_helper from messing with the PATH when starting tmux.
# See: https://superuser.com/a/583502 # See: https://superuser.com/a/583502