1

This is my ~/.bashrc:

# ...unnecessary lines skipped...
# man colors
LESS_TERMCAP_mb=$(tput blink) # start bold
LESS_TERMCAP_md=$(tput setaf 2 ; tput bold) # start bold
LESS_TERMCAP_me=$(tput sgr0)  # turn off bold, blink and underline
LESS_TERMCAP_so=$(tput smso)  # start standout (reverse video)
LESS_TERMCAP_se=$(tput rmso)  # stop standout
LESS_TERMCAP_us=$(tput smul)  # start underline
LESS_TERMCAP_ue=$(tput rmul)  # stop underline
export LESS_TERMCAP_mb
export LESS_TERMCAP_md
export LESS_TERMCAP_me
export LESS_TERMCAP_so
export LESS_TERMCAP_se
export LESS_TERMCAP_us
export LESS_TERMCAP_ue

This works, I can see colors in man pages. But when I move that lines from ~/.bashrc to ~/.profile (and re-login), the colors in man pages disappears.

I really want to use tput because it is more clear than a heap of control symbols.

Why do tput not working from .profile?

2

tput is not working because it needs to know current terminal emulator from $TERM environment variable. When ~\.profile is reading, there's just no terminal emulator in use, so tput just can't produce any output.

It is possible to specify which terminal capability to use in tput by -T key. So this code will work:

LESS_TERMCAP_mb=$(tput -T ansi blink) # start bold
LESS_TERMCAP_md=$(tput -T ansi setaf 2 ; tput -T ansi bold) # start bold
LESS_TERMCAP_me=$(tput -T ansi sgr0)  # turn off bold, blink and underline
LESS_TERMCAP_so=$(tput -T ansi smso)  # start standout (reverse video)
LESS_TERMCAP_se=$(tput -T ansi rmso)  # stop standout
LESS_TERMCAP_us=$(tput -T ansi smul)  # start underline
LESS_TERMCAP_ue=$(tput -T ansi rmul)  # stop underline
export LESS_TERMCAP_mb
export LESS_TERMCAP_md
export LESS_TERMCAP_me
export LESS_TERMCAP_se
export LESS_TERMCAP_so
export LESS_TERMCAP_ue
export LESS_TERMCAP_us

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.