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:
parent
e3c0bd323b
commit
42d84a2e12
1 changed files with 15 additions and 11 deletions
26
zsh/zshenv
26
zsh/zshenv
|
@ -20,17 +20,21 @@ export PAGER=less
|
|||
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/startup.py"
|
||||
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|
||||
|
||||
# Make man pages pretty
|
||||
rst="$(tput sgr0)"
|
||||
export LESS_TERMCAP_md="$(printf '%s\n' 'setaf 3' | tput -S)"
|
||||
export LESS_TERMCAP_mb="$LESS_TERMCAP_md"
|
||||
export LESS_TERMCAP_me="$rst"
|
||||
export LESS_TERMCAP_us="$(printf '%s\n' 'setaf 7' 'smul' | tput -S)"
|
||||
export LESS_TERMCAP_ue="$rst"
|
||||
export LESS_TERMCAP_so="$(printf '%s\n' 'setaf 4' 'setab 0' | tput -S)"
|
||||
export LESS_TERMCAP_se="$rst"
|
||||
export GROFF_NO_SGR=1
|
||||
unset rst
|
||||
# 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)"
|
||||
export LESS_TERMCAP_md="$(printf '%s\n' 'setaf 3' | tput -S)"
|
||||
export LESS_TERMCAP_mb="$LESS_TERMCAP_md"
|
||||
export LESS_TERMCAP_me="$rst"
|
||||
export LESS_TERMCAP_us="$(printf '%s\n' 'setaf 7' 'smul' | tput -S)"
|
||||
export LESS_TERMCAP_ue="$rst"
|
||||
export LESS_TERMCAP_so="$(printf '%s\n' 'setaf 4' 'setab 0' | tput -S)"
|
||||
export LESS_TERMCAP_se="$rst"
|
||||
export GROFF_NO_SGR=1
|
||||
unset rst
|
||||
}
|
||||
|
||||
# Prevent path_helper from messing with the PATH when starting tmux.
|
||||
# See: https://superuser.com/a/583502
|
||||
|
|
Loading…
Add table
Reference in a new issue