I thought: “why not coalesce all the scripts into one, then I don’t have to write handlers for writing the history for each and every script that uses ghead in post #1”. The script in the post above, is a “one size fits all”, that is to be used from every app, with and without a selection. You have to see to that nothing is selected in order to get the dialog box, but it respects the previous contents of the clip board.
I have also fixed an issue whith Safari, when it gets to be obnoxious, and don’t let me copy the selection of the front window.
I saved it as an applet, with the name ghead, and set LSUIElements to 1 in its plist file to make it work from spotlight, and quicksilver flawlessly as well.
And as far as I know, I am done with it. I won’t write help file for this, so the basic idea is to mark or input the name of a header file, say stdio.h, or CFSet.h or something, and it will pop up in quicklook right in front of you. If XCode is still the default editor for c and h files, then the header file will pop up into XCode if you double click on it.
I must say I am fairly happy with the applet for displaying header files, so I thought I’d wrap the gman script: A shell script for using quicklook to display manual pages into the same kind of applet. Here it is
You make a service for it to execute the applet from the contextual menu the same way as described in post #8.
If the manual page looks like it is html formatted, then chances are big that the manual page will pop up in Safari or your default web-browser, should you double click on it in quicklook.
I have done something more to the logic of ghead, so that it won’t be baffled by a selection in your active window, that doesn’t return a result.
I have also tried to speed it a little bit up, but I realize I have to write the history to disk, to get it to be more responsive, and it isn’t that bad really. But who knows, those computer seconds do take a long long time.
PS. People who use this are also supposed to have activity monitor open. But now it dies after 2 minutes of inactivity, should the dialog of the faceless app disappear, without you being inclined to hide the frontmost apps to find it.
Due to the changes I have made, I don’t think that to be an issue anymore anyway.
A little script that shows the folders of a directory tree that contains scpt, applescript or scpt files, in a TextEdit window, then it asks you, and lets you open one of the folders if you want to.
It doesn’t play well with filenames that contains “.” (ellipsis) and such.
If you have your script folders in just one place, it would be practical, to subsitute a hard path, for the choose folder dialog it starts with.
Here is one, you’ll like if you need to look at your own header files from within XCode, you just change the property revalInTextEdit to false, if you think an open dialog will suffice. You just change the script to use a posix path, if you have your stuff in one place, and customize it further, if you want to get at your locall library source files.
I have improved the three scripts in post #17 slightly with regards to search criteria, so that no double ticks, ment to escape the regexp are showing up in the dialog again.
I have updated the scripts in post #14,#15#16 and #17 Mostly with regard to layout, and made it easy to duplicate the script in post #17 to suit your own needs for other dedicated paths, as you usually know which framework, your are looking for an identifier in. (That is why I haven’t made it into one slough with a choose from list for picking framework.
For those of you fortunate enough to have such a new version of OS X that your Library aren’t indexed by spotlight anymore, please do try this:
do shell script " mdimport ~/Library"
I have gotten that line from Technical Q&A QA1475: Tips for searching Headers, APIs and ADC reference material.
But it should work equally well for stuff stored in the Library folder.
The Document just mentioned, puts the scripts in the posts above in a whole new light, making them less necessary, once you have read and adapted to the Q&A, but there should still be some use for them.
Here is a script for importing the headerr file for you for good measure (from 1475), I believe that you from Snow Leopard onwards then can write name: stdio.h for instance, in the Spotligt bar.
do shell script "mdimport /usr/include
mdimport /usr/local/include
mdimport /System/Library/Frameworks"
And while I am at it, here are two snippets for turning Airport on and off:
do shell script "networksetup -setairportpower en1 on"
I knew you’d guess it but:
do shell script "networksetup -setairportpower en1 off"
Should you have the need to debug quicklook, as it stops to work, then start looking for plugins that are in either /Library/QuickLook and ~/Library/QuickLook, and has a modification date back to 2007 .
This is script that installs a git repo for an Xcode 5 project when either you are upgrading the project to Xcode 5, or forgot/refused to install a git repo in the first place.
You should stand on the root folder of the project in a Finder window, and execute the script from there. The folder structure of the Xcode project should be willy nilly, with a folder within the root folder of the project that carries the same name.
The script is kindof a state machine. It works as it should, but may be hard to modify.
You may want to modify it slightly if you are running Xcode 3 or Xcode 4 alongside Xcode 5.
global theLoc
set situ to 1
installGitRepo(situ)
on installGitRepo(situ)
global theLoc
tell application "Finder"
try
if situ = 1 then
set theSel to selection
if theSel is {} then error number 3000
set theKind to class of item 1 of theSel
if theKind is not folder then error number 3000
set didSelect to false
else
set theSel to {}
set end of theSel to choose folder default location theLoc with prompt "Select Xcode root folder."
set didSelect to true
end if
set theName to name of item 1 of theSel
if not didSelect and not (exists folder theName of (item 1 of theSel)) then error number 3001
set pxPath to quoted form of POSIX path of (item 1 of theSel as alias)
set repoExists to (do shell script "cd " & pxPath & "; test -d .git && echo \"true\" || echo \"false\"") as boolean
if repoExists then
display alert "A git repository is already in place"
if situ = 2 then set target of Finder window 1 to item 1 of theSel
set situ to -1
else
--every thing so far is okay time to create the git repo.
set pxPath to quoted form of POSIX path of (item 1 of theSel as alias)
do shell script "cd " & pxPath & " ; mkdir .git ; cat \"UserInterfaceState.xcuserstate
build
*.pbxuser
*.perspectivev3
*.mode1v3
*~
*~.nib
*~.xib
.DS_Store
xcuserdata/\" >.git/.gitignore;git init; git add .; git commit -m \"initial commit\""
display alert "Successfully created .git repo for Xcode Project " & theName
if situ = 2 then set target of Finder window 1 to item 1 of theSel
set situ to 0
end if
on error e number n
if n = -128 then
set situ to -3
else if n < 3000 then
display alert "Unrecoverable error:
" & e
set situ to -2
else if n = 3000 then
set theTarget to name of its target of Finder window 1 -- as alias as text
display alert "No folder selected in " & theTarget
set situ to 2
else if n = 3001 then
set theFolder to name of item 1 of theSel
display alert "No folder of folder " & theFolder & " named " & theFolder & ".
The folder can't be the root folder of an Xcode project."
set situ to 2
end if
end try
if situ > 0 then set theLoc to target of Finder window 1 as alias
end tell
if situ > 0 then
installGitRepo(situ)
else
if situ = 0 then
set theLoc to missing value
if running of application "Xcode" is true then
tell application "Finder" to display alert "You must restart Xcode to make it acknowledge the repo."
else
tell application "Finder" to display alert "You can start Xcode to use source control."
end if
else if situ = -1 then
tell application "Finder" to display dialog "Do you want to create a repo for another folder?" with icon note
set situ to 1
installGitRepo(situ)
end if
end if
end installGitRepo