Hi guys, I combined DJ’s command at #12 with Stefan’s script at #16 to allow for access without the terminal and optional sections, as well as an attempt to comply with Stefan’s implied urging
-- Apple freeBSD man pages, local, pdf
-- opens local man pages in Preview as pdf.
-- using scripts by DJ Bazzie Wazzie at #12 and by StefanK at #16 in http://macscripter.net/viewtopic.php?pid=160863#p160863
display dialog "Enter the page name" & return & "(optional with section in parentheses)" default answer "mv(1)" with title "Apple freeBSD man pages, local, pdf" buttons {"Cancel", "OK"} default button 2
set manCommand to text returned of result
set leftParenthesisOffset to offset of "(" in manCommand
if leftParenthesisOffset = 0 then
do shell script "man -t " & manCommand & " | open -f -a preview"
else
set rightParenthesisOffset to offset of ")" in manCommand
set section to text (leftParenthesisOffset + 1) thru (rightParenthesisOffset - 1) of manCommand
set manCommand to text 1 thru (leftParenthesisOffset - 1) of manCommand
do shell script "man -t " & manCommand & " | open -f -a preview"
end if
Hi McUsrII,
I tried the bash script but, I can’t make it work. I copied the script to a UTF-8 text file, saved it to the desktop as gman, and did chmod u+x gman in the terminal. Then, I entered gman launchd.plist. I got this: -bash: gman: command not found.
What am I doing wrong?
You can cd ~/Desktop and issue: ./gman launchd.plist (or any other command!)
You can also start it by: ~/Desktop/gman launchd.plist
If you like it, then I recommend you install it somewhere, instructions follow below:
Try echo $PATH in your terminal window, copy gman to one of the folders that are showing up when you do that command. the folder should be local, so if you haven’t ~/bin in your PATH variable, then try this in your .bashrc file:
PATH=~/bin:$PATH
After any other PATH statements you may have. And if you don’t have a .bashrc file, then look for .profile or .bash.profile in your $HOME folder.
And copy gman to that folder before you cd somewhere else, and see if it works. I hope you like it.
That’s exactly what I did before. I tried that again and got this:
Mac-1:desktop chris$ ./gman launchd.plist
-bash: ./gman: /bin/bash¨if: bad interpreter: No such file or directory
I tried again from scratch, copying your code and so on. ”> no change.
Then it occurred to me that your posted code may have some extraneous end of line characters, and created the text file again by copying just the visible characters on each line. A bit tedious but ”> SUCCESS
I think that either you used some funny editor (unlikely) or, the forum’s code tags are playing jokes. Anyway, it works now. Many thanks
I put it on the desktop just for testing. Once it works, I have a place for all my command line tools.
If you’re not comfortable with textWrangler yet, you should definitely take a look at Sublime Text 2. In my opinion the best text editor (for developers) available on the Mac
I have standardized on vi for heavy chores, but this is not for everybody.
I use Iterm, and vim, I have full syntax completion for both C and Objective-C and C++ thanks to LLVM.org and very nifty plugin named youcompleteme. Together with all the nice stuff. C-tags and cscope, so I can navigate all the ways I want, also back and forth between visited places in the code.
I move easily in the error list, I cand do a grep in my project source, and move back and forth in that list, tracing stuff. GDB is integrated, so I can watch the code while I trace.
vim is incredibly fast to use, and as compatible with applescript as sublime I guess. But you have to know your way around, to leverage upon this of course.
But I am so happy with vi and iTerm nowadays, that I can’t express it. Not substitute for XCode of course, but I can have both.
There is a downside however, and that is that I tend to get strings with jjjjjjjjjj,s hhhhhhhhhhhh’s kkkkkkkkkkk’s and lllllllll’s before I realize where I am.
I updated the gman script in post #20 It now uses the mandoc macro package that discovers any other.
I have also removed some error messages if there are any parsing errors of the man page for display by groff.
This makes gman unusably for debugging manpages, which is ironic, given the Debug title and all.
I have updated the script in post #20, to use a unique tmp file, for the case you load the manpages from qlmanage and into Safari, by clicking on a section link, and then makes Safari refresh a previously loaded page.
Also sends qlmanage to the background so you can continue working in the terminal window, while watching the manpage.
I have posted the very final version of gman in post #20. It now tells you that you have to check in another section of man pages, if you have specified a section, where the man page wasn’t found.