Hi Paul,

I'll give you a few other alternatives to using man from the terminal command 
line.  First of all, in addition to Jon's suggestion of displaying in Preview, 
there's an alternative command that will send your man page output to TextEdit. 
 You can also set up scripting definitions for both of these by creating a file 
named ".profile" under the top level of your user account.

Jon's example was:
man -t bash | open -a preview -f

Here's another way to get the same "man" command to display in TextEdit:
man bash | col -b | open -f -a TextEdit

The output isn't as fancy, since PostScript output was meant to produce printed 
copies with bold and italic fonts, but the overhead on the system is lower, 
because before Preview can display PostScript output it has to convert it to 
PDF. On the other hand, in TextEdit VoiceOver will tell you that various system 
command words are "misspelled" -- which may be an advantage if you want to be 
flagged about this, but which is also likely to be annoying.

The reason for piping your man page entry to the "col" command with the "-b" 
argument before sending results to TextEdit is that in order to handle bolding 
and underlining of some words in the man page in terminal, extra controls are 
inserted that mess up the formatting if you simply redirect the output of the 
"man" command to a file.  Piping the results of the "man" command to "col -b" 
filters out the line feeds and also removes backspaces.  That output can then 
be piped to TextEdit.

And incidentally, just a minor comment on the explanation that Chris gave --  
in the old days of text processing there was a Troff program for printing 
PostScript output.  The original name came from a predecessor program named 
"Runoff", that gave rise to another program known in Unix circles as "nroff" 
(for "new roff"). Troff and nroff are still around, but are proprietary, so the 
GNU foundation produced "groff".  The reason that the switch is "man -t" is 
because the "t" stood for troff (PostScript formatted) output.  

I created shell definitions for "pman" and "tman" commands in my .profile file. 
 This dot file (named for the period that precedes the name, and that announces 
this to be a "hidden" file) contains the following definitions:

pman()
       {
       man -t "${1}" | open -f -a /Applications/Preview.app/
       }
tman()
       {
       man "${1}" | col -b | open -f -a "TextEdit"
       }

So, on my system I can go to Terminal and type "pman <some command>" and have 
the man page displayed in Preview, or type "tman <some command>" and have the 
man page displayed in TextEdit.  Incidentally, I know that the first argument 
uses full path name to the application and the second just uses the application 
name, but I created these definitions at different times, so I didn't use the 
same protocols.

All this command line maneuvering is interesting, but I'd actually make a much 
simpler recommendation to most people who want an easier way to view man pages: 
just get the freeware Bwana application from bruji.com:
http://bruji.com/bwana/

Put this into your Applications folder, and then you can use your browser to 
view man commands. Then you can simply type:
man:bash in your browser's URL field and press return to display the man page 
for "bash" or substitute the command of your choice.

HTH.  Cheers,

Esther


On Feb 9, 2012, at 6:41 AM, Paul Erkens wrote:

> Clear, as always. Thanks Chris.
> On Feb 9, 2012, at 5:00 PM, Chris Blouch wrote:
> 
>> Right. Postscript is a language created by Adobe for resolution independent 
>> page layout. It was first used by Apple in laser printers where the 
>> resolution had become so high that it was not reasonable to download an 
>> entire bitmap for a page. Instead Postscript lets you define objects such as 
>> a circle via a center point and a radius to make an "O" or the like. 
>> Needless to say Postscript is a whole giant complex language unto itself, 
>> groff knows how to create it and Preview knows how to interpret it. 
>> Postscript is also what makes a PDF work under the hood. PDF containers add 
>> things like fonts, images, indexing, links and more but the basic page 
>> layout is postscript.
>> 
>> CB
>> 
>> On 2/9/12 10:07 AM, Paul Erkens wrote:
>>> Hi CB,
>>> And now this is clear as well. Thanks a bundle. So what groff does is take 
>>> man's output, in whatever format man outputs it, and then reformats that 
>>> into postscript, whatever that is. I'll be reading.
>>> Paul.
>>> On Feb 9, 2012, at 4:00 PM, Chris Blouch wrote:
>>> 
>>>> Didn't see an answer yet so let me try.
>>>> 
>>>> 1. man -t routes the output of the man page through groff which defaults 
>>>> to making it into Postscript and then Jonathan piped that postscript into 
>>>> the OSX Preview app. Gives you a nice formatted output in a more Mac 
>>>> friendly viewer.
>>>> 
>>>> 2. I think most of your question will be answered if you do a "man open". 
>>>> The open command opens some file just as though you had done an Command-O 
>>>> in the finder on it. The -a modifier specifies which application to use to 
>>>> open the file and the -f option tells it to read input from standard in 
>>>> rather than a file, which would be needed to accept input from the pipe's 
>>>> output.
>>>> 
>>>> CB
>>>> 
>>>> On 2/9/12 6:11 AM, Paul Erkens wrote:
>>>>> Hi Johnathan,
>>>>> 
>>>>>> Looking at the command you gave:
>>>>>> man -t bash | open -a preview -f
>>>>> I have 2 questions.
>>>>> 
>>>>> 1. man bash or man -t bash. What is groff? From man, I don't become any 
>>>>> wiser. It seems that man -t bash, will have man pass its output to groff, 
>>>>> rather than to stout, while groff in turn, does pass it to stdout with a 
>>>>> lot of modifications. What is it that I see, when I enter man -t? Groff 
>>>>> is a front end for something else that I completely don't understand. 
>>>>> Question here is: what are you doing, using man -t?
>>>>> 
>>>>> 2. The output from man, traveling through gruff by means of the man -t 
>>>>> option, is then piped into the preview command. So far so good. But what 
>>>>> is the -f preview option for? I googled a lot but where do you find the 
>>>>> preview mac command line options? Question here is: what is -f doing in 
>>>>> preview?
>>>>> 
>>>>> I understand the -a switch for open. If this were not in place, then the 
>>>>> open command, a mac specific one I know now, would never know where to 
>>>>> look. -a Specifies to look inside the applications folder, wherever that 
>>>>> resides. Can you please answer my 2 questions above?  It looks like each 
>>>>> new answer poses new questions, but that will settle down over time I 
>>>>> hope.
>>>>> 
>>>>> Paul.
>>>>> On Feb 9, 2012, at 4:10 AM, Jonathan C. Cohn wrote:
>>>>> 
>>>>>> The prompt string  is defined in the variable PS1 for the bourne shell.  
>>>>>> I believe that bash  (bourne again shell ) also uses this variable.  
>>>>>> Note: you only need to set it, no need to export it to the environment.
>>>>>> 
>>>>>> First check to verify the shell you are running
>>>>>> echo$shell
>>>>>> 
>>>>>> then run a man page on the shell (if you want to get fancy , then code 
>>>>>> like the below should bring up the man page in preview...
>>>>>> 
>>>>>> man -t bash | open -a preview -f
>>>>>> 
>>>>>> But then again, google can find man pages, and there is actually a 
>>>>>> option in Google settings to indicate that you want a UNIX man page when 
>>>>>> you enter  "man XXX" in the google search bar.
>>>>>> 
>>>>>> Best wishes,
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Jonathan C. Cohn
>>>>>> [email protected]
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Feb 8, 2012, at 8:54 AM, Paul Erkens wrote:
>>>>>> 
>>>>>>> Dear list,
>>>>>>> 
>>>>>>> I am learning to change the terminal prompt. It now includes my machine 
>>>>>>> name and my user name, which is what I want to get rid of. I think that 
>>>>>>> the prompt is contained in an environment variable. I found that I can 
>>>>>>> look at them by using env without parameters, and that works. However, 
>>>>>>> prompt is not in here. Where do I need to look, to find the 
>>>>>>> placeholders string that gives me my prompt?
>>>>>>> 
>>>>>>> Paul.
>>>>>>> 

-- 
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/macvisionaries?hl=en.

Reply via email to