Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

8 Answers

up vote 27 down vote accepted

Use this function in .bashrc:

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

Source

share|improve this answer
2  
Thanks! This is better than gedit too (didn't know about yelp) –  Zabba Apr 20 '11 at 0: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
1  
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
add comment

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.

share|improve this answer
    
An alternative command that avoids the creation of a temporary file, making use of Bash features: gedit <(man bash) –  Lekensteyn Dec 23 '11 at 11:06
1  
@Lekensteyn: gedit doesn't open a <() process substitution, nor does it open piped input. (tested in 2.30.3, and 3.4.1) –  Peter.O Sep 4 '12 at 6:21
    
@Peter.O I just checked and you are true. It does not work for kate either. nano can open it as read-only though. –  Lekensteyn Sep 4 '12 at 11:34
add comment

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
until [ -z $1 ]
do
    # if the manpage was found, spawn it in a browser window
    man -f $1 > /dev/null && coproc man --html=firefox $1
    # go to next parameter
    shift
done
share|improve this answer
    
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 4 '12 at 7:02
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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 :)

share|improve this answer
    
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 4 '12 at 6:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.