Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It would be nice if we made better use of full-colour terminal support.

    man() {
    	env \
    		LESS_TERMCAP_mb=$(printf "\x1b[38;2;255;200;200m") \
    		LESS_TERMCAP_md=$(printf "\x1b[38;2;255;100;200m") \
    		LESS_TERMCAP_me=$(printf "\x1b[0m") \
    		LESS_TERMCAP_so=$(printf "\x1b[38;2;60;90;90;48;2;40;40;40m") \
    		LESS_TERMCAP_se=$(printf "\x1b[0m") \
    		LESS_TERMCAP_us=$(printf "\x1b[38;2;150;100;200m") \
    		LESS_TERMCAP_ue=$(printf "\x1b[0m") \
    		man "$@"
    }
And it would be really nice if I could read man pages in the terminal in a proportional font, but preserving alignment etc.

(See also, a script to display an image in the terminal: https://git.gnome.org/browse/vte/tree/perf/img.sh?h=vte-0-36 )



> And it would be really nice if I could read man pages in the terminal in a proportional font, but preserving alignment etc.

Most man utilities can write postscript instead of directly to terminal. You can use that to achieve exactly what you want. Though this is not exactly in the terminal itself.

Example: I don't have zsh for comparison but on my OS X machine, running `man -t bash | open -f -a Preview` results in this: https://dl.dropboxusercontent.com/u/845567/bash%281%29.pdf


That is beautiful! I didn't realize you could pipe into OSX's `open` util. (or how big the man page for bash really is!)

Here's zsh: https://drive.google.com/file/d/0B_jWp8d11aB5Wi15eVdJS1Nhdk0...


> I didn't realize you could pipe into OSX's `open` util

It kinda sucks that you can't just pipe directly to Preview, but I suppose we should be grateful this wonderful pipeline does actually work!


Is there a way to avoid Times New Roman? Some of the characters are pretty ambiguous. I remember, back when I used that command, I mixed up an l and a 1 for one of the flags.


To be pedantic, the font you're seeing isn't Times New Roman, but rather Times. They're similar, but there are subtle differences.

Yes, you can choose a default font. You need to change your /etc/man.conf, find the line that starts with TROFF, and add new options. For example, to use Palatino as the default font, you should additionally provide the option `-f P`. Then you'll get this output: https://dl.dropboxusercontent.com/u/845567/bash%281%29%20Pal...


> To be pedantic, the font you're seeing isn't Times New Roman, but rather Times. They're similar, but there are subtle differences.

And there's an interesting history to that split: https://en.wikipedia.org/wiki/Times_New_Roman#Linotype_relea...


Just like my AT&T 3B2 manual from 1985!


If instead of -t you pipe the output of the manpages into groff which is responsible for the file type, formatting, etc there is a font-family flag.


On OS X 10.11.6, Preview fails with "The PostScript file "open_afberandom.txt" could not be converted to a PDF file." :(


For once, I'm glad I'm still running 10.9.5. Can anyone confirm whether issue is unique to OP or something broken in OS 10.11?


Worked on my machine with 10.11.6.


> And it would be really nice if I could read man pages in the terminal in a proportional font, but preserving alignment etc.

People would need to use tabs (gasp) instead of spaces for that :-P


> People would need to use tabs (gasp) instead of spaces for that :-P

That would be madness.


Yea, why use a character for what it's supposed to do when you can use 40+ year old workaround for broken editors?


You could just do a naive 4spaces to 1tab conversion.


This breaks for spacing between non-whitespace character. E.g. the list of flags, which may have varying lengths, but all descriptions start on the same alignment.

    This is a man page with a list of flags below

    --flag1        Description of flag1
    --secondflag   Description of secondflag
If we naively replaced the above with 4spaces=1tab we'd get the whitespace between flag1 and its description replaced with two tabs, and we'd get the whitespace between secondflag and its description left as a string of three space characters.

I have no idea what is actually used in man pages for alignment and spacing, but the example above is only to illustrate that 4space=1tab breaks even on trivial examples as a conversion rule.


That does not matter for single dash and letter options. For double dash long options I like to split them on different lines so that you still have a lot of horizontal space for the descriptions themselves even with very ling option names, so a brute force way:

  This is a man page with a list of
  .I flags
  below
  .P
  .BR --flag :
  .RS
  Description of flag1
  .RE
  .P
  .BR --secondflag :
  .RS
  Description of secondflag
  .RE
  .P
Also for real tables:

  $ man tbl


> And it would be really nice if I could read man pages in the terminal in a proportional font, but preserving alignment etc.

Since you want proportional fonts, you'd have to be willing to leave the terminal already. If so, I'm aware of three options:

1. the classic, xman: fugly

2. the builtin, "man -H": it works sometimes. On my own system, the it's so unreliable that I'd call it alpha-stage software

3. and Konqueror. Works perfectly every time, but you'd have to install KDE components.


Manpages are written in troff: https://manpages.bsd.lv/

This means that they can be converted to PostScript or PDF. There’s no portable way to do this with the “man” command, but on most Linuxes you can use “man -t” and on a system using Mandoc you can use “man -T pdf”.

Likewise, for HTML, “man -H” is not strictly portable, but only works on certain versions of Linux; a Mandoc system would let you use “man -T html”. (The only strictly portable, as in “POSIX specified,” flag for man is -k.)

Honestly it might be better to just get used to using an existing webpage for your distribution. For example, OpenBSD’s web manpage database (based on Mandoc) is very nice: http://man.openbsd.org/ls.1


> and Konqueror. Works perfectly every time, but you'd have to install KDE components.

For that matter, any KDE application that handles URLs can retrieve HTML-formatted man pages thanks to KIO slaves.

You want the source of the HTML-formatted man page so you can edit it and save your edited copy? OK:

    $ kwrite 'man:/usr/share/man/man1/ls.1p.gz'
KIO man also offers indices, as well. For example, you can get a list of all commands by going to man:/(1)


One could also use Emacs (in a graphical window rather than in the terminal) `woman` and `variable-pitch-mode`.


I don't understand 3.? Konqueror is the KDE3 web browser - how's that relevant here?


Konqueror is still included in current versions of KDE Applications (effectively 5.x, but the term "KDE 5" isn't really used).

Also, it's not so much a Konqueror thing as it is a feature of KDE's URL-handling subsystem. Any KDE application that interacts with URLs can retrieve HTML-formatted man pages. If you don't like Konqueror, you can always use Rekonq. Or you can open the source code in KWrite or Kate. Or you can browse man indices in Dolphin as if they were directories (though the actual pages will open in Konqueror).

KIO slaves are wonderful, wonderful things. It's the same technology that lets you use fish:// to access files and directories over SSH in every KDE program that deals with URLs (and since the file open/save dialogs are URL-based, this means it'll work with anything that uses those dialogs).


Thanks, yeah I used to use fish:/ and fonts:/ and a couple of other kio slaves, just not man, low discoverability I guess. I thought kio slaves had died with KDE5 [that's still the right name IMO despite the framework:applications split].

TIL.


Yeah, they neutered a lot of stuff with KF5 (the elimination of KLocale honestly makes me want to go back to Windows), but KIO is still around.

Unfortunately, it looks like fonts:/ was never ported to KF5, but fish:// and a bunch of others are still around.


Konqueror has man: and info: IOslaves (KIO plugins) allowing it to natively handle local man and info pages.


That assumes that the terminal has full-color support.

It would be even better to use a sane default supported by all terminals (the ugly 16-color one), and enable full-color only on terminals known to support it.

There is probably an exact-but-complicated way to do this. All I do to determine 256-color support is to check for a -256color suffix in the TERM variable.


The terminfo database records how many colours a terminal supports: if the shell command `tput colors` prints 256, then your terminal is configured to support 256 colours.

Unfortunately, there's no standard database field to record the presence of truecolor support; even if there were, there's terminals (like xterm, for example) that understand the control-sequences but map them to the nearest colour in the 256-colour palette rather than using them as-is.


>That assumes that the terminal has full-color support.

As it should (assume and have) in 2016.


I'm 99% sure those are colour control codes, but what does that huge env string actually do?


Temporarily adds the LESS env settings below on top of your existing env entries, for as long as you run man.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: