20

When I type man bash it shows the info in the terminal itself.

How do I tell "man" to open up the info in gedit instead? Is this possible?

Cas
  • 8,557
Zabba
  • 3,555

8 Answers8

32

Use this function in .bashrc:

man () { yelp "man:$@"; }

Source

zengr
  • 808
  • 2
    Thanks! This is better than gedit too (didn't know about yelp) – Zabba Apr 20 '11 at 00:00
  • 3
    Or just use yelp man:bash of course, if you are on somebody else's desktop. – JanC Apr 20 '11 at 12:18
  • 2
    And if you need a manpage that's not in the default section, use something like yelp "man:init(5)" instead of man 5 init (this doen't work with the current version of zengr's bash function). – JanC Apr 20 '11 at 13:47
  • That's very good. Still, I'd also like a method to index or browse the man pages by topic or a table of content. Is there anything like that out there that works on say just ubuntu or even just debian with X? – will Oct 01 '15 at 14:18
4

Simply enter the following in the terminal:

man bash >/tmp/t;gedit /tmp/t

That will create a temporary file with the contents of the man page and open it with gedit.

Nathan Osman
  • 32,155
3

Better yet, have man format it in HTML and open it in firefox

#!/bin/bash
# open a man page in firefox

# loop through all parameters in order
for i
do
    # if the manpage was found, spawn it in a browser window
    man -f "$i" > /dev/null && coproc man --html=firefox "$i"
done
muru
  • 197,895
  • 55
  • 485
  • 740
Bill
  • 31
  • 1
  • Excellent, I love it. +1 .. It is now a function in my ~/bashrc ... fman () { until [[ -z $1 ]] ;do man -f "$1" 2>/dev/null && coproc man --html=firefox "$1"; shift; done; } – Peter.O Sep 04 '12 at 07:02
  • truly amazing. this way text overflows normally from a line to the next. – user3804598 Apr 02 '23 at 09:10
1

As well as opening the man page in gedit (like the other answers have demonstrated), you can also make a pdf of the man page (as first noted in this article) and then display it in evince. (You need ps2pdf and evince installed). The pdf file is created in your present working directory and is retained after evince is closed.

Simply modify the command below according to the man page that you want and change the file names or else the resulting pdf files will be overwritten. Here is an example for dpkg:

man -t dpkg | ps2pdf - dpkg.pdf && evince dpkg.pdf

However, it is probably much more useful to construct a function. You could add the following function to your .bashrc or .bash_aliases (assuming you have evince and ps2pdf installed; the latter is in the ghostscript package):

mikman() { man -t "$1" | ps2pdf - "$1".pdf && setsid evince "$1".pdf; }

After adding the function, you have to run . .bashrc (or . .bash_aliases) to source your configuration files, or restart the terminal for it to take effect.

Call the function with the name of any program that has a manpage, such as mikman dpkg, and it will carry out the commands and launch the manpage as a pdf. Launching the manpage as a pdf in your pdf reader gives you a very useful gui wherein search tools and the like can be utilised.

  • This is the best because it actually runs full preprocessors typeseting things like eqn(1) equations (man -t glFrustum), pic(1) diagrams (man -t soelim), tbl(1) tables (man -t nft) etc! . It's also possible to use TeX's dvi format instead of postscript, for even better results (especially for eqn formulas): man -Tdvi glMultMatrix > t.dvi && dvipdfmx t.dvi && xdg-open t.pdf – Beni Cherniavsky-Paskin Apr 27 '22 at 06:51
1

If you don't want to use a shell: hit alt+f2 and enter yelp man:bash. A command history is also available, and you can choose any manpage by replacing man:bash with the manpage you need.

nanofarad
  • 20,717
cosmo
  • 11
0

You can browse man pages on-line http://manpages.ubuntu.com/ or install dwww package and browse all documentation off-line (http://localhost/dwww). See description of dwww package and/or read man dwww after installation.

You may be also interested in browsing package contents – install dpkg-www package and do the same: See description of dpkg-www package and/or read man dpkg-www after installation. Start dpkg-www or browse http://localhost/cgi-bin/dpkg.

0

On a case-by-case basis you can do:

man mount > mount.txt

The .txt file will be in your current directory.

man mount > mount.txt && gedit mount.txt

will open the file in gedit.

boehj
  • 2,051
-1

This will create a temporary file with the manual page for bash in your home directory entitled "man" and open it with gedit. As soon as you close gedit the file will be erased too. Just replace bash with whatever man page you want to open.

man bash >> ~/man && gedit ~/man && rm ~/man

Hope this helps :)

scay
  • 1
  • The problem with this is that gedit detaches itself from the terminal with an exit code of 0, so the rm step is executed immediately. This causes ~/man to be deleted before gedit has even loaded it... – Peter.O Sep 04 '12 at 06:31