11 ms·
Colorized man pages
- mih 10y agoIf you're using oh-my-zsh, you can just enable the colored-man-pages plugin
- tomtomtom777 10y agoAlthough the author uses zsh, the function works other shells as well; at least on bash.
- jlebrech 10y agoyep, I can't tell the difference. oh-my-zsh much have it by default
- kseistrup 10y agoOr you could just use most(1) as MANPAGER. http://www.jedsoft.org/most/ http://www.jedsoft.org/most/
- therealmarv 10y agoomg, why do I discover this only now? thanks.
- neuromute 10y agoThat site needs some updating. The 'features' and 'images' sections both lack content (merely a message stating "under construction"). Although content > style, I can't help but mention how dated the site looks also.
- kseistrup 10y agoYou're right, that webpage is sh*t. Nevertheless, that's the official webhome for most(1) which should be readily installable in most Linux distros.
- neuromute 10y agoI just installed it... it works beautifully. Thanks for the heads up!
- cm3 10y agoI wouldn't go that far. That and other sections of the website may be incomplete, but the pages load quickly, don't require a multitude of JS calls or other slowdowns. I love pages that do what they're meant to without unwarranted bloat. Gmail and Github use JS for web apps, and that's okay, but a static page doesn't need that and is worse off if they incorporate it. If you go to a random wikipedia article and try to click through references and land on a newpaper's site, 4 out of 5 times the link will be dead. So much for complex CMS installations. I'm (not) sorry that I prefer web pages that work more than ones that chase some short-lived frontend tech. With all that being said, I'm sure the author would appreciate a contribution to fill in the blanks.
- karl42 10y agoLooks great! There's some info and a screenshot on the debian package page: https://packages.debian.org/sid/most https://packages.debian.org/sid/most The official website doesn't really contain any information.
- pbhjpbhj 10y ago"most" is impossible to search. "mostpager" would have been better with a soft-link from most as default. Anyway, how do I use it, I've sudo apt install-ed it. Scanning the manpage doesn't give me any great hints e.g. "most /usr/share/man/man1/apt-add-repository.1.gz" brings it up but the manpage shows control data; using as if it were man just fails (it thinks I'm passing it a file). Hint? Or do I need to read the source ...
- 1_player 10y agoIf I recall correctly... add to your .bashrc export PAGER=most or for my fish friends, add to ~/.config/fish/config.fish set -x PAGER most This'll use `most` everytime a pager is needed (i.e. git log), if you want to use `most` only for man pages, replace PAGER with MANPAGER
- chanux 10y agoOn fish same effect could be achieved by running set -Ux PAGER mostU If you prefer to keep fish.config cleaner, that is :)
- kseistrup 10y agoEither export PAGER=most or export MANPAGER=most depending on whether you want to use most for all paging or just paging of man pages.
- znpy 10y agomost is literally the first package I install on every box on which I get or am given admin right. It works so well it is unsane not to use it. Thank God I saw that name while installing Slackware a long time ago, and since then it had been a pleasure to use.
- andlrc 10y agoI use vim as a manpager. This way I get all my binds for navigating (I mapped <c-e> to scroll two lines, etc), colors is supported and folds.
- lucb1e 10y agoJust installed most, but it doesn't support scrolling via the j and k keys. I'd have to move all the way over to the arrow keys. This is not a replacement for less. Uninstalling.
- devnonymous 10y agoOr pinfo which supports both man and info pages.
- devnonymous 10y agoOr pinfo which supports both man and info pages.
- Symbiote 10y agoIt 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.
- dkharrat 10y agoIs there an advantage to overriding the man command over the approach of just directly exporting the env variables in bashrc? I currently do the latter and I don't override the man function. I suppose overriding the man function would allow for man-specific customizations, but perhaps there are other good reasons too?
- JoshTriplett 10y agoYou might not want to override termcap for less in other contexts. Or not in the same way.
- tuananh 10y agodoesn't work very accurate for me. tried with `man curl`
- bramblerose 10y agoCompared to the original formatting, this colorization does the following: - normal text stays the same color, - bold text (bright white) becomes red, - underlined text becomes green, - inverted text becomes yellow-on-blue However, if the original does not use bold or underlined text to emphasise parts of the text, this re-formatting has no effect. This is what happens in the curl documentation, where the command-line options are in regular text rather than bold text.
- keeperofdakeys 10y agoThere is also a vimscript to turn vimpager into a man pager, which supports basic colouring.
- akerro 10y agoI found this script on reddit once. It does the same but sets random colors for man pages. https://gitlab.com/agilob/.files/blob/master/mancolor.sh https://gitlab.com/agilob/.files/blob/master/mancolor.sh
- phunehehe0 10y agoFirst I thought random colors might just be a "because I can" thing, but the script apparently keeps consistent colors for each man page. Now I wonder if it has a use case...
- akerro 10y agoMost often it's really nice looking. https://gitlab.com/agilob/.files/raw/4249f5d58aca984ef32af761b6366d6383c15e2c/man_page.png https://gitlab.com/agilob/.files/raw/4249f5d58aca984ef32af76...
- wtbob 10y agoIf each man page has different random numbers (perhaps seeded on the man page section and name), then I could see that it might be a memory aid, kinda like having different floors of a building painted different colours, while different layers have different carpeting and different organisations inside the building have different artistic styles: one's subconscious learns what one's environment indicates, and it makes navigation much easier.
- IshKebab 10y agoStorming into the 1980s...
- pixelbeat 10y agoI use vim to get colorized pages and drill down to other referenced man pages. Search for MANPAGER in: http://www.pixelbeat.org/settings/.bashrc http://www.pixelbeat.org/settings/.bashrc
- cpr 10y agoIs the "env" really necessary? I thought if you just prefixed the eventual 'man "$@"' with those environment variable settings that it would have the same result.
- deleted 10y ago[deleted]
- ksherlock 10y agosure, except instead of running [/usr/bin/]man, it will run the man shell function.
- Myrmornis 10y agoAre man pages basically just a slab of informally structured prose, or do they stick to some sort of grammar? I.e. Can they be parsed? Can I query one for something like "the meaning of the command line short option -a", or am I stuck trying to use the pager's search functionality for "-a"?
- anjbe 10y agoMandoc, the default manpage formatter in OpenBSD, Illumos, Minix, and some Linux distributions, does semantically parse manpages. The latest version even uses less’s tags functionality to allow jumping to flag definitions. For example, if I “man ls”, I can then type :tx to go to the definition of the -h flag, without hitting any false positives like a text search might. http://mdocml.bsd.lv/ http://mdocml.bsd.lv/
- gautamsomani 10y agoBeautiful. Thanks. :)
- pwenzel 10y agoFor my Fish shell comrades, see http://askubuntu.com/a/650192 http://askubuntu.com/a/650192.
- amyjess 10y agoOh, this is wonderful. For the last few years, I've been going out of my way to add color to my terminal output, making use of things like COPE and zsh-syntax-highlighting. This will be a wonderful addition to that.
- AceJohnny2 10y agoAs a tangent, I remain impressed by manpage's staying power. GNU tried to move ahead with Info, a tree-based doc format and viewer, but that never really seems to have taken off, possibly due to UI issues (I'm always confused about how to use it) It's a pity: have you tried searching for something in, say, Bash's manpage? It's just a flattened version of its doc, and you're completely flooded with search results. I suppose manpages are another example of "worse is better". They are extremely simple to use, which is what you want when you're frustrated and looking for that *$#& option to 'find'. And yet, the troff/groff formatters used by manpages can be pretty sophisticated (Kernighan mentioned in an interview [1] he still used it to write books, eschewing to complexity of Latex) and can produce a variety of formats, such as HTML or PostScript. Why don't distributions make more use of this? I miss the days where you could "man foo" in KDE's quick launch bar and get a nicely HTML formatted version in Konqueror. [1] https://rkrishnan.org/posts/2016-03-07-how-is-gopl-typeset.html https://rkrishnan.org/posts/2016-03-07-how-is-gopl-typeset.h...
- BurningFrog 10y agoI still use manpages now and then. But only by googling them.
- akkartik 10y agoManpages as "worse is better"? Them's fighting words :) I think it's more an example of how GNU isn't Unix, for better and for worse[1][2]. Info seems to be deeply integrated with the Emacs mindset, so coming from a different editor it's got some learning curve. Except it never seemed to be setup properly by default on a new server, and when I installed something new I'd never remember what I had to do to add it to the root page. Many's the time I tried to info for something and got.. its manpage, but in a crappier setting. Scanning a large manpage with '/' seems far superior to playing whack-a-mole with Info's tree structure. I don't want to sip documentation with a straw, just give me the firehose. (This is also why I prefer 'man zshall' rather than the trying-to-be-helpful sections of the zsh manpage. Who in god's name remembers which of those sections the factoid they're looking for is going to be in?) All this would be surmountable if Info worked consistently out of the box. But the combination of encountering it only intermittently in working fashion meant that any lessons I learned quickly evaporated, and had to be repeatedly relearnt. I'm very happy now that GNU systems have given up on trying to make Info happen. Documentation quality is all about the quality of the content. Working on the tools instead of the content is classic bikeshedding. (The one great advance in Unix documentation recently is git's approach of opening the man page when you type --help.) [1] http://queue.acm.org/detail.cfm?id=2349257 http://queue.acm.org/detail.cfm?id=2349257 [2] http://landley.net/aboriginal/history.html http://landley.net/aboriginal/history.html
- noobermin 10y agoHmm, man is colored and has been for a few years or so on my box by default?
- gnyman 10y agoFor people on OS X I recommend checking out Bwana https://www.bruji.com/bwana/ https://www.bruji.com/bwana/ ,it's not the same thing, it's man pages in your browser but in combination with Alfred (or similar) and/or a terminal plugin it's great. I find it much faster to skim man pages with bwana. Main issue is of course that this shows man pages for OS X, which is usually similar but not identical to the ones on your favourite distro.
- to3m 10y agoIf you like bwana, you could try my updated copy: https://bitbucket.org/tom_seddon/bwana https://bitbucket.org/tom_seddon/bwana (I've put a compiled version in the releases page - if it doesn't work, you can hopefully build it yourself) Main improvement: man pages generated with this version include more links. Any time it spots a word that's bold, or underlined, or whatever it is - I don't remember what it was exactly - rather than just printing it that way it tries to turn it into a link to the man page by that name, if there is one.
- rurban 10y agoI like that, thanks!
- kazinator 10y agoThat is awesome, ... and it cures the stupid underline disease! What I'm talking about is that text which is marked up as a code (monospaced font) in the troff source being rendered annoying as bold and underlined! That creates ambiguities with actual underline characters and general readability nuisance. With these settings, the underlining is gone.
- Annatar 10y agoA good example of how function definitions in shell can be used to overlay commands (applications). The man() shell function in the example, although slick, is terribly inefficient because every time the man(1) command is called, the function will execute multiple printf(1) applications, over and over and over again. If you've ever ran application startup and shutdown at the assembler level in a debugger, it became obvious pretty quickly than running an application involved many, often recursive libc and system function calls, just to be able to set up the environment in order to start and exit the application. Here, then, is the fix; this runs only once at shell startup, and stores the resulting escape codes in variables; put this in your ~/.profile (not .kshrc, nor .bashrc, nor .bash_profile, but ~/.profile!): LESS_TERMCAP_mb=`printf "\e[1;31m"`; export LESS_TERMCAP_mb LESS_TERMCAP_md=`printf "\e[1;31m"`; export LESS_TERMCAP_md LESS_TERMCAP_me=`printf "\e[0m"`; export LESS_TERMCAP_me LESS_TERMCAP_se=`printf "\e[0m"`; export LESS_TERMCAP_se LESS_TERMCAP_so=`printf "\e[1;44;33m"`; export LESS_TERMCAP_so LESS_TERMCAP_ue=`printf "\e[0m"`; export LESS_TERMCAP_ue LESS_TERMCAP_us=`printf "\e[1;32m"`; export LESS_TERMCAP_us this code is portable and should work on every Bourne-family shell from the original '70's Bourne shell all the way to ksh93 and bash without modification; if it does not, it is a bug in the shell interpreter. Bug your operating system vendor to fix the interpreter program. it should be noted that this assumes that the terminal (or the terminal emulator) one is using is actually capable of correctly interpreting the escape command sequences, and in addition correctly displaying them. Not all terminal emulators nor all physical terminals are capable of displaying all, some or any of these display modes. The above also assumes that the shell implements \e, which not all shells do (C-shells notably do not). Finally, a quick crash course on manual pages, manual pages versus info, and why manual pages are orders of magnitude better, and still a standard, because that is bound to come up sooner or later: https://news.ycombinator.com/item?id=11927525 https://news.ycombinator.com/item?id=11927525
- kazinator 10y agoBit of a "useless use of env" here. You don't need the env program for establishing environment variables for the execution of a command. That is a built-in shell feature: VAR1=val1 VAR2=val2 ... command However, env here is serving the purpose of avoiding unwanted recursion, because "env man" runs the external man rather than the function. But we can get that with the "command" builtin, or by using "/usr/bin/man": Thus: man() { LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_me=$(printf "\e[0m") \ LESS_TERMCAP_se=$(printf "\e[0m") \ LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ LESS_TERMCAP_ue=$(printf "\e[0m") \ LESS_TERMCAP_us=$(printf "\e[1;32m") \ command man "$@" }
- javaJake 10y agoReally interesting thoughts coming from the groff mailing list: "Because of poverty owing to neglect -- that is, necessity being the mother of invention -- the author of the article I linked to decided he'd like color in his man pages. Where did he turn? A style sheet in the groff framework, perhaps? Any kind of improvement to the semantic-display connection? No, he reached about as far down as possible, and tweaked the control sequences emitted to the emulator. Because he could. Because, in a way, he had to, insofar as that strange bit of arcania gave him the most leverage. "So, yes, he's still working with a text terminal, after a fashion. But the programmability of that text terminal is an accident of history, its feature set long since made obsolete -- not useless, but out-moded -- by graphical displays and GUIs. That he reached for that particular tool is a measure of how far we have come, and how far we have not." https://lists.gnu.org/archive/html/groff/2016-08/msg00034.html https://lists.gnu.org/archive/html/groff/2016-08/msg00034.ht... Thread root: https://lists.gnu.org/archive/html/groff/2016-08/msg00013.html https://lists.gnu.org/archive/html/groff/2016-08/msg00013.ht...