• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Make Bwana work with recent Safari releases
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make Bwana work with recent Safari releases


  • Subject: Re: Make Bwana work with recent Safari releases
  • From: Stan Cleveland <email@hidden>
  • Date: Wed, 30 Oct 2013 12:05:43 -0700

On Oct 29, 2013, at 3:09 PM, Lists wrote:

I finally got tired of not being able to display a formatted man page in Safari 6 and up using Bwana. For Example, man:ls, in Safari's address bar simply brings up a Google search page - No help.

The following script run from the Scripts menu gets formatted man pages back in Safari (if it is default browser).

# This script snippet will open man pages in Safari 6.x using Bwana.
# Prior to Safari v6, typing "man:command," e.g. man:ls, in Safari's location field would open a formatted man page. Now that initiates a search instead.
# Run this from the Scripts menu with Bwana installed anywhere you like. Bwana never actually opens but Safari will display a formatted man page for a command entered.
# Bwana is here.  http://www.bruji.com/bwana/index.html

set x to text returned of (display dialog "Enter the name of a Unix manual to open." default answer "ls" buttons {"Cancel", "OK"} default button 2)
set mancmd to "man:" & x
open location mancmd

Hi "Lists",

Personally, I'd avoid third-party Bwana and the reliance on Safari. I'd take advantage of 
built-in, Apple-supported shell commands to make a formatted man page—like this:

-- prompt for command name
set shellCmd to text returned of (display dialog "Command to man:" default answer "ls")
try -- be sure command is available
do shell script "which " & shellCmd
on error
display dialog ("Shell command \"" & shellCmd & "\" wasn't found.") buttons "Cancel"
end try
-- save man page as PDF on Desktop
set manPagePath to "~/Desktop/"
try
do shell script "man -t " & shellCmd & " | pstopdf -i -o " & manPagePath & shellCmd & ".pdf"
do shell script "open -a preview " & manPagePath & shellCmd & ".pdf"
on error errText number errNum
if errNum is 232 then -- make PDF by alternate method
do shell script "man -t " & manPagePath & ".ps > " & manPagePath & shellCmd & ".ps"
do shell script "open -a preview " & manPagePath & shellCmd & ".ps"
set dialogMessage to "Please save the open man page as a PDF."
displayDialog(dialogMessage, "Cancel", 1, 0)
else if errNum is 234 then -- no man page available
display dialog ("No man page exists for \"" & shellCmd & "\".") buttons "Cancel"
else -- throw the error
error errText number errNum
end if
end try

Stan C.
-------
Lists? Is that to starboard or to port?  :-)

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Make Bwana work with recent Safari releases (From: Lists <email@hidden>)

  • Prev by Date: Re: Article on missing Applescript in new iWork
  • Next by Date: Re: Article on missing Applescript in new iWork
  • Previous by thread: Make Bwana work with recent Safari releases
  • Index(es):
    • Date
    • Thread