0

Many non alpha-numeric characters appear as jumbled mess when using less and man. Currently, I'm using zsh but the same problem happens in bash and sh. The problem also appears in both the st and termite terminal emulators.

man grep produces:

Broken man page

How can i fix this?

env -i TERM=$TERM PATH=/usr/bin:/bin HOME=/none man grep renders correctly.

7
  • 2
    it is not a jumbled mess ... those are VT100 commands that tell the terminal window how to format the displayed text ... your terminal program does not understand the commands – jsotola Nov 11 '20 at 0:20
  • I get the same issue in xterm as well. – jeohd Nov 11 '20 at 0:31
  • If less -R works, add export LESS=-R to your ~/.bashrc. Read man less. – waltinator Nov 11 '20 at 0:48
  • it may be a messed up prompt doing this (PS1) ... does the same thing happen if you log in as root? – jsotola Nov 11 '20 at 1:54
  • 1
    @waltinator, the man-db implementation of man should already set $LESS to something like -ix8RmPm. Also, these days, those escape sequences tend not to be used by default (you'd need to set the GROFF_SGR env var), so there's something unusual in the OP's environment. See also Grep: unexpected results when searching for words in heading from man page – Stéphane Chazelas Nov 11 '20 at 7:52
1

Since the problem disappears with a minimal environment, it's caused by an environment variable. It turns out to be your LESS_TERMCAP settings. You've set them to sequences beginning with [. They're missing the initial escape character.

csi=$(printf '\033[')
export LESS_TERMCAP_mb="${csi}1;31m"
…
0

These vars were exported in my ~/.profile. Removing them solved the issue.

export LESS=-R
export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')"
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')"
export LESS_TERMCAP_se="$(printf '%b' '[0m')"
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"

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.