7 ms·
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") \
by Symbiote 10y ago
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 https://git.gnome.org/browse/vte/tree/perf/img.sh?h=vte-0-36 )
- rangibaby 10y ago> 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
- allendoerfer 10y ago> People would need to use tabs (gasp) instead of spaces for that :-P That would be madness.
- coldtea 10y agoYea, why use a character for what it's supposed to do when you can use 40+ year old workaround for broken editors?
- Senji 10y agoYou could just do a naive 4spaces to 1tab conversion.
- greggyb 10y agoThis 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.
- mzs 10y agoThat 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
- deleted 10y ago[deleted]
- voltagex_ 10y agoI'm 99% sure those are colour control codes, but what does that huge env string actually do?
- coldtea 10y agoTemporarily adds the LESS env settings below on top of your existing env entries, for as long as you run man.
- lake99 10y ago> 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.
- pbhjpbhj 10y agoI don't understand 3.? Konqueror is the KDE3 web browser - how's that relevant here?
- lloeki 10y agoKonqueror has man: and info: IOslaves (KIO plugins) allowing it to natively handle local man and info pages.
- amyjess 10y agoKonqueror 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).
- pbhjpbhj 10y agoThanks, 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.
- ckastner 10y agoThat 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.
- thristian 10y agoThe 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.
- coldtea 10y ago>That assumes that the terminal has full-color support. As it should (assume and have) in 2016.
- kccqzy 10y ago> 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 https://dl.dropboxusercontent.com/u/845567/bash%281%29.pdf
- zo7 10y agoThat 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/view?usp=sharing https://drive.google.com/file/d/0B_jWp8d11aB5Wi15eVdJS1Nhdk0...
- oneeyedpigeon 10y ago> 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!
- 0942v8653 10y agoIs 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.
- hashmymustache 10y agoIf 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.
- kccqzy 10y agoTo 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%20Palatino.pdf https://dl.dropboxusercontent.com/u/845567/bash%281%29%20Pal...
- Asooka 10y agoIf you use KDE, you can read man pages in konqueror with the man:// scheme. For example, man://ls shows you the man page for ls. The links at the bottom are also real links that take you to the linked man pages. It's honestly a really nice man viewer but very inconvenient to invoke from anywhere.