6 ms·
Using Spotlight from the OS X Commandline
- _pdeschen 14y agoIt's nice to have access to such UI components from the command line. One of my favorite is pbpaste/pbcopy. What's yours?
- elithrar 14y ago$ softwareupdate -i -a [install, all] as it avoids the (slow) UI and you can schedule it if you want to. Not sure if it'll carry across to ML, what with updates going through the Mac App Store there.
- activepeanut 14y agoOne downside worth mentioning is that you can't read the full description of each available updates, like you can when you click on an item in the GUI version.
- _pdeschen 14y agoIndeed. Moreover, I only want to update my jdk when Im ready and have some free time to repair my jdk 1.5 symlinks once the update completes.
- jasomill 14y agosoftwareupdate -d -a downloads all updates to /Library/Updates. For each update, you get a .pkg file to install and a metadata file that includes this description.
- riobard 14y ago`security` lets you manipulate your Keychains. `say` lets you do text-to-speech in command line.
- Watabou 14y agosay is pretty useful and fun. When I'm compiling or just telling the Terminal to do something tedious, I add a say command at the end and it will notify me when it's done. For example, if I want to install mercurial and git with homebrew: brew install git mercurial; say "The task is finished, Master."
- jasomill 14y agoAs an aside, in Lion at least, you can download high-quality voices for dozens of languages in Speech Preferences (including the ones Apple uses for Siri in several countries).
- riobard 14y agoI used to SSH into my wife's Mac and asked her to come over if we are in different rooms :)
- Tarlitz 14y agoA more silent option is to print the bell character to the terminal, ie.: sleep 5; printf '\a' This will cause the terminal to bounce and add a little badge with the number of tasks that require your attention if it's out of focus :)
- bpierre 14y ago`open` is very convenient to… open things (see `man open`). Tip: `open .` opens the current directory in the Finder.
- jasomill 14y agoAnother tip: open vnc://[user@]host[:port] connects as user to host on port with Screen Sharing, and, more generally, "open URL" works for any URL scheme registered with Launch Services, including, but not limited to, the obvious ones.
- jasomill 14y agoosascript of course: it lets you control the UI of Cocoa applications, and even more for scriptable ones: osascript -e 'tell application "Safari" to close every document ¬ whose url contains "news.ycombinator.com"' (¬, option-(lowercase L), is the AppleScript line continuation character)
- kghose 14y agoOn my mac command+space switches the input mapping. Just sayin'
- eloisius 14y agoI'm interested in accessing this programmatically, of course. I've been thinking a lot about "Memex" lately, and the Spotlight index could be a very good engine for that.
- alister 14y agoI am very fond of the Mac, but the developers of Spotlight and the recent Versions feature of OS X Lion have not given proper thought to users' security and privacy. Spotlight peeks inside files to create an index, and Version-supported apps maintain a changelog of file diffs. These OS X features save data in hidden locations, separate from the file. This means that: (a) it is very difficult to delete a file and be certain it's really gone, (b) you can't have a public area, a private area, and a highly confidential area on the same system; it's all commingled to the same level of privacy, (c) you can't make a backup of the non-confidential files without risk of getting the confidential files too, (d) pieces of an encrypted file (if you use TrueCrypt for example) might get saved unencrypted in Spotlight's and Version's hidden locations, I could go on, but you get the idea. It breaks down the notion of a file having a distinct level of security or privacy, and doesn't replace it with a better notion. We already had the following problems: (1) deleting a file doesn't really remove it on any major OS, including OS X, unless you use a special shredding program, and these days even shredding may be ineffective on solid-state drives because of wear-leveling and caching, (2) the swap space can contain pieces of a file, (3) temporary files created by editors, word processors, and other apps might retain parts of file. Now Spotlight and Versions make the problem even worse for Mac users who care strongly about privacy and security. We're getting to the point--or probably well past the point--where you have to maintain at least 2 or 3 separate systems: one for public work, another for personal or private work, and a third for highly confidential work.
- mkaltenecker 14y agoThat seems like an excellent trade-off to me, a prime example of how Apple is great at picking the right trade-offs. All what you said is completely irrelevant for the vast majority of people. So Apple doesn’t trade it off against the increased convenience both Spotlight and Versions give you.
- alister 14y agoirrelevant for the vast majority of people In real life people do think of pieces of paper as having different levels of security or privacy. Some pieces of paper you can leave out on the coffee table, others get locked in a desk, and still others in a safety-deposit box. Also, as separate point, your use of the word "trade-off" assumes that there is no alternative other than giving the user some complex privacy-aware UI or complicated procedures.
- sgt 14y agoSeems like alias locate='mdfind' is in order (on my system).
- jasomill 14y agomdfind is basically orthogonal to locate (doesn't match individual files inside packages; handles wildcards differently), but it does produce find(1)-compatible output, which is nice: http://jasomill.at/mdfind-dired.el http://jasomill.at/mdfind-dired.el