Man; I wish I knew this many years ago

man is a handy terminal command for looking up how to use other bits of macOS Unix subsystems

Usually though I end up opening 2 terminal since man pipes its output through a pager - which is handy and to at the same time
It means you CAN scroll forwards & backwards but you can have the command docs and type at the same time
One you end the output its no longer on screen

So a recent question prompted me to go peek at how to use man better

And I found pman
A command you can add to your shell and it pops up Preview with a nice formatted document
The entire command is

 man -t <THE SPECIFIC MAN ITEM OR FILE YOU WANT TO SHOW HERE> | open -f -a Preview

and of course you an add it to zsh by opening .zshrc
edit the file and add

pman() {
    man -t $@ | open -f -a Preview
} 
 

now you can type

pman ls

and get this

4 Likes

nice but does not work anymore with ventura as preview does not open ps files anymore … :frowning:

edit: you can use Skim to open and convert ps files on ventura.

Well this all stemmed from a long conversation Norman and I had the other day while I was trying to figure out how to do this

This still has a bit more work to do on it.

So if anyone has “feature ideas” let me know :slight_smile:

FYI… 100% Swift

2 Likes

Sucks for people on Ventua
I’m not so doesnt impact me but eventually will

man, and its support programs, do support other output forms like html

@JeanYves you can use the ‘pstopdf’ command line tool to convert postScript format files to PDF’s.
And then you can open the created PDF document with the ‘Preview.app’.

This is an example based on Normans script, but made as an AppleScript.

set toolName to "ls"
set manPDFPath to "/tmp/" & toolName & ".pdf"
set manPDFFile to do shell script ("man -t " & toolName & " | pstopdf -i -o " & manPDFPath)
delay (1.0)
set openManPDFFile to do shell script "open " & manPDFPath & " -a Preview"

Regards Mark

1 Like

@MonkeybreadSoftware Norman’s forum post was about easily accessing the man pages of a command line tools.
As far as I can tell, it has nothing to do with using Xojo.
So why would anyone consider paying for irrelevant and unnecessary plugins ?
When there is a free readily available tool built into the operating system.

2 Likes

This is just my hint, that if Norman likes to automate this with a Xojo app to convert the Postscript from man page output to PDF, he can use the plugin.

And if Dave wants to do the same in his app, he can check CGPSConverter functions in CoreGraphics framework, which should also be useable in Swift.

1 Like

@MonkeybreadSoftware Norman was sharing his method using a shell script, to open man pages as a PDF in Preview.
A Xojo automation project was never mentioned or implied.
Dave like myself codes in Swift for Apple platforms, and like myself thinks Xojo sucks.
And his project as shown was being written in Swift, so sgain no Xojo needed there either.
So it seems to me like your simply hijacking this thread to flog your irrelevant plugins.

The Preview thing won’t work anymore with MacOS Ventura. Did you miss that?

So at least this script needs a tool like ps2pdf to run there.

A bit of ghostscript and you can view it there is no plugin needed and no Money to do that on Ventura

https://web.mit.edu/ghostscript/www/Ps2pdf.htm

Is for free of charge the plugin is not

2 Likes

@MonkeybreadSoftware I’m not on Ventura, I was simply trying to show a free easy way of converting Postscript files to PDF’s.
And unlike you, I’m not looking to fleece people of there money, for any help I offer on forums.
And if I where on Ventura, I would still find a free native way to do it, without nonsense plugins.
So my point here is, your irrelevant plugins are not needed for anything related to this thread.

2 Likes

Since we are talking about MAN and Ventura…

I found out today after conversations with @HalGumbert (who is running Ventura)
that Apple has drastically changed the CLI arguments for the MAN command.
Luckily we found an easy alternative so my app can move forward

The “man -wK” doesn’t work and you need to use “manpath” instead. And I’m sure that is not the ONLY change Apple made.

2 Likes

That’s even better than my Solution, thanks for that. Nothing needed all is onboard. #macisbest

I’m using just the cmd line - no Xojo involved
The app I AM writing that I needed to poke around the cmd line is in C#

Daves using Swift

No Xojo involved in either project

2 Likes

pstopdf should suffice

and should work on Catalina Monterey Big Str & Ventura

not sure if it will require an actual file or not as that seems to be what pstopdf does

Yeah the ‘pstopdf’ shell script does work on Catalina Big Sur and Monterey.
Dave said that the man command line tool has changed on Ventura, but I’m sure there is a way to create a similar shell script to do the same thing on Ventura.
But until I upgrade to Ventura, I can’t speculate how the shell script would need to change.

Regards Mark

This conversation has been investigating what file formats I will be able to get my app to export to.
but that is a few steps down on my punch list.

1 Like

@npalardy according to this article.

https://scriptingosx.com/2022/11/on-viewing-man-pages-ventura-update/

you may be able to change your original script to work on Ventura as well as the earlier MacOS’s

I have changed my AppleScript to this.

set toolName to "ls"
set manPDFFile to do shell script "mandoc -T pdf \"$(/usr/bin/man -w " & toolName & ")\" | open -fa Preview"

which works on my Monterey partition.
But I don’t have Ventura to test if the code works.

2 Likes

Which part of

“Or use CGPSConverter via declares if you prefer.” and “he can check CGPSConverter functions in CoreGraphics framework”

did you not understand?

@JuliaTruchsess I understand that this forum thread is about shell scripting, nothing else.
If you actually go to the top of the thread, and read Norman’s original posting.
He was sharing a shell script on how to display command line tool manual files in a Preview window, as opposed to the Terminal window.
Dave was showing an app he is making with Swift in Xcode, to do the same thing in an app window.
‘JeanYves’ was Ponting out that in Ventura, the Preview app no longer converts a PostScript files to text or PDF format.
And I was pointing ‘JeanYves’ in the direction of the ‘pstopdf’ command line tool, to convert the PostScript file into a PDF before trying to open it in Preview.

At no point was Xojo ever in anyway related to this forum thread, so to ‘use CGPSConverter via declares’ in Xojo is totally and utterly irrelevant.
Monkey Bread’s Xojo plugins are also redundant in this topic, as guess what !
This thread has nothing to do with Xojo, so Xojo plugins are also not require.
Monkey Bread’s Xojo plugins, are only ever required in Xojo projects, to fill in all the gaping holes in Xojo’s capabilities.

The other way you can tell this thread has nothing to do with Xojo, is that I was part of the conversation.
If this thread did have something in anyway related to Xojo, you would not see me here, as unlike you, I learned that Xojo is not worth my time and energy to talk or even think about.

This forum in general is not specifically a Xojo forum, it is for users of many different languages and developer tools., so you’ll find many non Xojo related forum threads, and most of the ones that are related to Xojo, are usually critical of that third rate developer tool, an rightly so.

But luckily for me, this particular forum thread HAS NOTHING TO DO WITH XOJO.
It’s about shell scripting, that doesn’t require that awful Klingon like syntax used in Xojo declares.

Do you understand ?

2 Likes