Here’s the Man Page AppleScript: 1: use AppleScript version "2.4" - Yosemite (10.10) or laterĤ: - This script is expected to be run either with the command name selected (as ifĥ: - by double-clicking) or with the cursor within the command name. I then select Man Page from the Scripts menu-or, more likely, use the ⌃⇧M shortcut I’ve assigned to it-and up will pop a new window with the chmod man page. ![]() I can either double-click to select chmod or just single-click to put the cursor within the word. Say I’m in SEE ALSO section of the ls man page, and I want to open the chmod man page that’s referred to there. So I wrote an AppleScript (BBEdit has great AppleScript support) that uses the cursor postion or the selected text to open a new page. The bold characters that I’d see if I ran man lsĭon’t appear in the BBEdit window, but I’ve never gotten any value out of that limited sort of text formatting, so I don’t miss it.Īlthough most of what I do in a man page is search and read, sometimes I like to use the hints within the text to open a new, related man page. So if I type bbman lsĪt the command line, a new BBEdit window will open 1 with the text of the ls man page. I’ve also changed the name of the command from bman to bbman to better fit the naming pattern set by bbedit, bbfind, and bbdiff. -t $cmd sets the title of the document to the command name.-clean sets the state of the document to unmodified so you can close it without getting the “do you want to save this?” warning.-view-top puts the cursor and the scroll position at the top of the document.It incorporates options suggested by readers to the bbedit command in the pipeline of Line 16: This is slightly different from the code I originally posted. Set the titleġ5: # of the window and scroll to the top.ġ6: man $sec $cmd | col -bx | bbedit -view-top -clean -t $cmd As with `man`,Ĥ: # the section is optional and comes first if present.ġ3: # Get the formatted man page, filter out backspaces and convert tabsġ4: # to spaces, and open the text in a new BBEdit document. So you don’t have to go through the terrible burden of reading an earlier blog post, here’s the source code of the command I use from the Terminal (or iTerm) to open man pages in a new BBEdit window: bash:ģ: # Interpret the arguments as command name and section. The posts reminded me that although I wrote about how I open and read man pages in BBEdit last year, I never showed how I use references to related man pages as links. ![]() Julia Evans has been posting on Mastodon recently about the GNU Project’s insistence on documenting its commands through info pages instead of man pages and (the following may be biased by my own thoughts) how absolutely awful that is. Next post Previous post Again with man pages and BBEdit
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |