How to support this blog?

To support this blog, you can hire me as an OmegaT consultant/trainer, or you can send translation and project management jobs my way.

Search the site:

Showing posts with label Spotlight. Show all posts
Showing posts with label Spotlight. Show all posts

Easily launch scripts from Spotlight

I've been advertising AppleScript a lot here. Automating a task is something, but easy access to that automation is quite important too.

Since I try to stick to Apple solutions and free software* I prefer using Spotlight instead of all the smart launchers that we have for macOS.

What I do is that I call my script names that are easy to call first in Spotlight. A few screenshots speak louder than words so here we are:

The series that start with ">" usually is scripts that I use to open something.

See how just typing ">" suggests ">BB". That ">BB" is what I use to open the files selected in Finder with BBEdit.

The one below is ">Tedit", short for "TextEdit" and opens selected files in TextEdit, etc.



If I type "c" after ">", I get the following list of choices. ">command" is to launch an arbitrary command in Terminal, ">Capture" is to use org capture in Emacs (see here and here for more information) and ">cd" just opens a Terminal tab on the front Finder window, or selected Finder folder.


When I use "<" to initiate the search, I get a different list. That series is for scripts that usually act by themselves. "<text file" creates a text file in the front Finder window and proposes to open it in BBEdit for editing, "<facturation" is an invoicing script for the job selected in Finder, "<job" is a job managing script that creates a job hierarchy in Finder based on a mail, along with an event in calendar, and then "<xls2tmx" is a TMX converter for multicolumn Excel reference data (I'll publish it when it's more polished, but creating XML data with AppleScript is documented here).


I have a few more scripts (a dozen) that I routinely call with Spotlight, which I find totally sufficient for my needs.

As you know, hitting Command+Enter when you have a selection in Spotlight is a way to reveal that selection in the Finder if it is available. So when I want to edit a script, I start by calling it in Spotlight, I hit Command+Enter when it is selected and then I call ">SEditor" (Script Editor) or ">debugger" (Script Debugger) on the selection, to open it with the appropriate application...


Ok, I do have BBEdit, Microsoft Office and Illustrator... And maybe a few others...

"Open With" too many applications...

All this started a few weeks ago, and it is most probably related to Leopard's Time Machine. It may be related to other things too but then I have no idea what they are. The result is that you end up with duplicates of all your applications popping up here and there, first in the SpotLight result window, then in Mail, when you right-click on an attachment, in Finder too...

Sometimes you launch the backup instead of the original, and you realize when the backup disks starts to scramble like crazy...

Eventually, I found a solution. A little drastic, and maybe it was not all necessary, but it also contributed to rationalize my backup procedures.

Before:

1) Time Machine copied _all_ my disk to an external backup disk
2) I had Sync!Sync!Sync! do an extra daily backup of my whole home hierarchy (including all the "user space" applications)
3) I had Spotlight index everything

What I wanted was Spotlight indexing everything _but_ the applications.

The problem was that the Privacy setting of SpotLight did not allow for the selection of a subfolder in the Time Machine backup (like Applications, for ex).

Now:

1) Time Machine copies everything but the system Application folder, the user Application folder, the whole Developer folder and the Download folder.
2) Sync!Sync!Sync! does an extra daily backup of my whole home hierarchy, including the user space Application folder
3) Sync!Sync!Sync! does also a daily backup of the system's Application folder
4) I have Spotlight index everything (including the TimeMachine backup, of course) but the Sync!Sync!Sync! backups where all the Application duplicates are now.

I have also reindexed Spotlight using the following command in Terminal:

 $ sudo mdutil -Es / /Volumes/backup_disk_name/


And I have rebuilt the LaunchServices database, the one that contains all the "knowledge" about which application is supposed to launch which file, with the following command, also in Terminal:

 $ /System/Library/Frameworks/CoreServices.framework/\
Versions/A/Frameworks/LaunchServices.framework/\
Versions/A/Support/lsregister\
-kill -r -domain local -domain system -domain user


SInce the whole "recipe" is based on saving applications outside Time Machine, I also had to erase all the data Time Machine had accumulated for a month... Setting Time Machine to not save /Applications from any day does not remove /Applications from the previous days backup sets... There may be smarter ways to do that, but I thought that with my already existing extra daily backup I was on the safe side.

Now, I have much saner "Open With" drop down lists when I right-click a file with my mouse...

What I like in OSX 10.5

Apple advertises over 300 new features in OSX 10.5. A lot of them have no immediate use for the translator but some of them really rock. 300+ New Features

Here is my current and most immediate pick. The list will grow as I use them in real life.

Spotlight



I never really used Spotlight, even on my relatively fast MacBook. Instead I had Butler as an application launcher and the standard Finder for file searches (even though the Finder used Spotlight technology).

Now, Spotlight is all this and more.


  • it displays applications first, so that you can really use it as an application launcher. Even though it is not as sophisticated as Butler, it does the job very properly.
  • searches are faster than on Tiger.
  • it calculates as you type a formula. I used PlainCalc for that before, and even though PlainCalc is much more powerful than Spotlight, the later is currently just what I need most of the time.
  • it acts as a (English) dictionary by showing you the first line of the definition of the word you type, clicking on the result will bring you to the Dictionary application.


Spotlight on Apple's "New features" page.

Dictionary



Dictionary now has a set of 3 Japanese dictionaries (Shogakukan) and also accesses Wikipedia in the main available languages. It is faster than launching Safari to find a reference online. The only drawback, when compared to Safari, is that Dictionary does not display the language versions links of the article you are reading which does not allow the user to jump to the target language in which the reference is sought.

Dictionary on Apple's "New features" page.

Automator



Automator now has a "Record" function that allows it to remember mouse activity on any application's menus. That allows for quick "macro" recording in applications that are not well integrated with OSX and/or that do not support AppleScript. Java applications for translators come to mind !

Automator on Apple's New features" page.

Popular, if not outdated, posts...

.docx .NET .pptx .sdf .xlsx AASync accented letters Accessibility Accessibility Inspector Alan Kay alignment Apple AppleScript ApplescriptObjC AppleTrans applications Aquamacs Arabic archive Automator backup bash BBEdit Better Call Saul bug Butler C Calculator Calendar Chinese Cocoa Command line CSV CSVConverter database defaults Devon Dictionary DITA DocBook Dock Doxygen EDICT Emacs emacs lisp ergonomics Excel external disk file formats file system File2XLIFF4j Finder Fink Font français Free software FSF Fun Get A Mac git GNU GPL Guido Van Rossum Heartsome Homebrew HTML IceCat Illustrator InDesign input system ITS iWork Japanese Java Java Properties Viewer Java Web Start json keybindings keyboard Keynote killall launchd LISA lisp locale4j localisation MacPorts Mail markdown MARTIF to TBX Converter Maxprograms Mono MS Office NeoOffice Numbers OASIS Ocelot ODF Okapi OLPC OLT OmegaT OnMyCommand oo2po OOXML Open Solaris OpenDocument OpenOffice.org OpenWordFast org-mode OSX Pages PDF PDFPen PlainCalc PO Preview programming python QA Quick Look QuickSilver QuickTime Player Rainbow RAM reggy regular expressions review rsync RTFCleaner Safari Santa Claus scanner Script Debugger Script Editor scripting scripting additions sdf2txt security Services shell shortcuts Skim sleep Smultron Snow Leopard Spaces Spanish spellchecking Spotlight SRX standards StarOffice Stingray Study SubEthaEdit Swordfish System Events System Preferences Tags TBX TBXMaker Terminal text editing TextEdit TextMate TextWrangler The Tool Kit Time Capsule Time Machine tmutil TMX TMX Editor TMXValidator transifex Translate Toolkit translation Transmug troubleshooting TS TTX TXML UI Browser UI scripting Unix VBA vi Virtaal VirtualBox VLC W3C web WebKit WHATWG Windows Wine Word WordFast wordpress writing Xcode XLIFF xml XO xslt YAML ZFS Zip Zotero