instant alert on replacing/overwriting a file in a folder

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

-- 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?

Hello.

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. :slight_smile:

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 :wink:
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 :smiley:

I put it on the desktop just for testing. Once it works, I have a place for all my command line tools.

Cheers, Chris

Do you have linefeed as line terminators and not returns? because of the “/bin/bashif” error it seems that the line terminator is wrong.

Sorry DJ, I don’t have the bad text file any longer. On my successful try, when I copies just the visible characters, I just typed returns.

Hello.

Do yourself a favor and get TextWrangler if you don’t have, then you can save the file with encoding utf-8 No BOM, and with unix linefeeds.

Just did and retired TextEdit from scripting duties :wink:

Good for you1 :smiley:

By the way, when having gman display a webpage: Have you tried to click on one of the generated links? :wink:

Try gman bash and then click on one of the links at the top if you click on NAME for instance, it’ll open in Safari, or your default browser I guess.

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

Hello :smiley:

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. :smiley:

Hello.

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. :slight_smile:

Hello.

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.

Enjoy!

Hello.

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.