Here is an Automator action I made for creating a new e-mail message with an attachment from the Finder using Sparrow. It is similar to the built-in service for Mail.
Just create a new service, specify that the "Service receives selected: Files or Folders" in "Any Application."
Then, add a "Run Applescript module". Copy and paste the code below.
This works with multiple attachments. Now you should have a contextual menu item after selecting items in the Finder. You can tweak this by opening Keyboard preference pane in System Preferences.
on run {input, parameters}
tell application "Sparrow Lite" -- or "Sparrow"
activate
set theMessage to make new outgoing message
tell theMessage
repeat with ii in input
make new mail attachment with properties {filename:ii as alias}
end repeat
compose
end tell
end tell
end run
[kirkmc adds: This was submitted by e-mail by Tom F. I don't have Sparrow to test it. One thought: at the beginning, should it really be for "Any Application?" This only works in the Finder, so I think it should be just the Finder in that part of the workflow.]
In Lion's Spotlight, type kind:web and Spotlight returns webarchive files. Type kind:webarchive, however, and Spotlight does not return any files.
This behavior happens in Lion and Snow Leopard. I have not tested previous Mac OS X versions.
[kirkmc adds: Yes, this is what happens. Oddly, webarchives aren't listed in Apple's Help entry on Spotlight keywords, and, in this hint from 2007, based on a blog post of mine, it's not present either. I've written a fair amount about Spotlight for Macworld (notably this 2008 article which features a long list of such keywords), and never mentioned webarchives.]
Assigning a shortcut to open Safari's current page in Google is simple but breaks frequently, because the menu item name includes Chrome's version number. The simple fix is to use an Apple Script like Mike Hardy's as a proxy to Google Chrome. I'm describing this in more detail in this blog post, which is also reproduced below.
Currently shipping Macs come without Adobe Flash Player preinstalled, and I’ve been running that same setup without Flash for quite a while now myself. More and more webpages work fine without Flash and only the occasional video requires it. When that is the case, I simply go to the Develop menu (enable it in Safari's Advanced preferences if you don’t have it) and select Open Page With > Google Chrome.app (20.0.1132.21). Since Google Chrome comes with Flash preinstalled, this is a simple way to switch to a Flash-enabled browser.
Now, rather than choosing Chrome from the menu it would be nice to assign a keyboard shortcut for this menu item, and this is actually quite simple: Open the keyboard preference pane in System Preferences, select ‘Application Shortcuts’ and add a shortcut for the Google Chrome.app (20.0.1132.21) menu item to Safari. However, the problem here is that the menu item contains the version number of Chrome and since Chrome updates frequently (and in the background), you’ll find yourself with a broken shortcut very soon.
The fix for this is a little Apple Script OpenURLInNewChromeWindow.app by Mike Hardy which tells Google Chrome to open the URL via an Apple Script command. If you run this script once, it will register itself as a application that can handle URLs, and will therefore also appear in the list of browsers under Open Page With. Opening a page with this script will open the current page in Chrome just like before, but the menu item will stay the same no matter which version of Chrome you have installed. You simply assign the shortcut to this "browser" instead of the ever-changing Chrome.
As an added benefit (and actually the reason Mike Hardy wrote the script in the first place) is that the page opens in a new window and not in a new tab (which can be quite annoying when using virtual screens). See Mike’s blog post for more details how to use his script in that context.
A recent hint described how to disable elastic scrolling in many Lion applications. You can disable this effect in iTunes alone by setting the hidden preference "disable-elastic-scrolling".
To turn off elastic scrolling in iTunes, enter this in Terminal:
[kirkmc adds: I find it interesting that this key uses the term "elastic" and the one in the previous hint uses "Rubberbanding." Which means that I had to make the title of this hint include both...]
In honor of the "sandboxalypse," or the day that Apple started imposing sandboxing rules on the Mac App Store, I thought it would be interesting to see how Mac OS X Hints readers use the Mac App Store. Head over to our new poll about the Mac App Store and software purchases.
Back in the day, prior to Leopard, there was a console.log file, which contains errors and messages for the current user's account. When Leopard came around, this file was removed, and the system-wide logging system (ASL) replaced it. Those messages are still recorded, but when you view logs in Console, you can't see them on their own.
I was doing some research today for an article, and wondered where that file went, and how one could view it, since the full system.log contains so many entries that it can be hard to wade through. I found a forum thread from 2008 which explains that you can see what used to be in console.log by running syslog -C in Terminal. You can also run this command to save these entries in a file, then view them in vim: syslog -C > /tmp/console.log; view /tmp/console.log. Or, if you simply want to save this information in a text file, you can do this: syslog -C > /Desktop/console.log.
While this isn't new, it's good to know, if you're looking through logs in Console in search of information.
There are plenty of hints on this site that use the defaults command to change preferences or settings that are unavailable via the GUI. These are fine to use for isolated changes, but there are some applications where you might want to change a number of settings.
iTunes is one of these. Over the years, Apple has removed a number of options from iTunes; at least from its menus and preferences. Many of these options remain, but are hidden.
Doug Adams' free Change Hidden iTunes Preferences is an applet that lets you change a number of settings. I use it to make sure that when I rip CDs, track numbers are added to the file names; to hide Ping buttons; and to hide the arrow buttons that display next to tracks. Other options it offers are the ability to turn on half-stars for ratings (useful for smart playlists), showing the "Libary" playlist at the top level of the iTunes source list, and to create playlists for new purchases such as albums.
This is a simple GUI tool that allows you to check some buttons and click Apply. So if you want to make changes to some of these hidden settings, check out this applet.
I love TextWrangler, and I have a Mac at work and one at home, but often do coding on both. I set up a system using Dropbox so both my preferences and my Application Support files sync so I always have my stationery files and the same settings, wherever I am.
Run the following as a shell script on each of the Macs. This will copy TextWrangler to your Dropbox folder, and create the support folder on Dropbox, then create a symlink to it in the correct location on your Macs. It will then copy the preference files to Dropbox, so when you launch the application on either Mac, you'll have the same setup.
#!/bin/bash
#+ Portable TextWrangler
#* Formatted date & time string.
FORMATTED_DATE=`/bin/date "+%Y-%m-%d%H%M%S"`
#+ Remove it from /Applications (optional, just so you can replace it with a ln to your dropbox)
sudo /bin/mv -f /Applications/TextWrangler.app ~/.Trash/
#* Add a link in /Applications to your DropBox copy
sudo /bin/ln -Fs ~/DropBox/TextWrangler.app /Applications/TextWrangler.app
#* Archive existing folder
/bin/mv -f ~/Library/Application Support/TextWrangler{,.$FORMATTED_DATE}
#+ Create cloud app support folder
/bin/mkdir -p ~/DropBox/TextWrangler
#+ Link cloud app support folder to your local workstation (this contains your stationery, etc.)
sudo /bin/ln -Fs ~/DropBox/TextWrangler ~/Library/Application Support/TextWrangler
#+ Create cloud app support folder for your preferences
/bin/mkdir -p ~/DropBox/TextWrangler/Preferences
#* Placeholder so your prefs go to the cloud
/usr/bin/defaults write ~/DropBox/TextWrangler/Preferences/com.barebones.textwrangler Placeholder true
#* Link cloud pref to your local workstation
sudo /bin/ln -Fs ~/DropBox/TextWrangler/Preferences/com.barebones.textwrangler.plist ~/Library/Preferences/com.barebones.textwrangler.plist
exit 0
[kirkmc adds: Personally, I wouldn't do it this way. For example, I don't see why you would copy the application itself to Dropbox; you can just have a copy on each Mac. You also might not want to have the preferences the same on both Macs, if one is a desktop and the other a laptop. So all that leaves is the support folder, which is easy to symlink.
If you want to do this with BBEdit, it's much simpler. As explained on the Bare Bones web site, BBEdit will look for the support folder on your Dropbox folder.]
These AppleScripts are related to this hint. Both can already be found in the replies to the hint topic post, but I'm resubmitting them so that they will appear together.
The first is an improved version of the original AppleScript which presents a dialog box from which a selection of local volumes to be ejected can be made. An example of its usefulness might be that it provides a reliable method for quickly ejecting a MacBook's mounted local volumes for users on the go. I've configured it as a "Run AppleScript" step for an Automator-based Mac OS X Service called "Unmounter" and assigned it the keyboard shortcut of (Command-Control-Shift-E) in System Preferences on my system.
The second is a more robust version of the AppleScript included in my first reply to the original hint topic. It attempts to automatically unmount all unmountable local volumes, and if it finds none, attempts to mount any local volumes that are available. I've configured it as a "Run AppleScript" step for an Automator-based Mac OS X Service called "Toggle Available Local Volumes" and assigned it the keyboard shortcut (Command-Option-Control-Shift-E) in System Preferences on my system.
For both Automator-based Mac OS X Services that I created to provide key triggers for the AppleScripts, the scope specified is "Service receives no input in any application."
set alldisks to paragraphs of (do shell script "df -hlg | awk -F/ '/disk*/ {print $5}'")
set nonbootnumber to (count of alldisks)
try
set alldisks to items 2 thru nonbootnumber of alldisks
activate
set your_selected_device_id to choose from list alldisks with prompt "Please choose one or more volumes to be unmounted." with multiple selections allowed
repeat with the_Item in your_selected_device_id
set the_ID to (do shell script "df -hlg | grep -m 1" & space & quoted form of the_Item & space & "| grep -o 'disk[0-9][a-z][0-9]*'")
try
do shell script "diskutil unmount /dev/" & the_ID
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end repeat
on error the error_message number the error_number
if the error_number is -128 or the error_number is -1708 then
else
display dialog "There are no unmountable volumes." buttons {"OK"} default button 1
end if
end try
set alldisks to paragraphs of (do shell script "df -hlg | awk -F/ '/disk*/ {print $5}'")
set nonbootnumber to (count of alldisks)
try
set all_non_boot_disks to items 2 thru nonbootnumber of alldisks
on error
set all_non_boot_disks to {}
end try
if (count of all_non_boot_disks) > 0 then
try
activate
repeat with the_Item in all_non_boot_disks
set the_ID to (do shell script "df -hlg | grep -m 1" & space & quoted form of the_Item & space & "| grep -o 'disk[0-9][a-z][0-9]*'")
try
do shell script "diskutil unmount /dev/" & the_ID
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end repeat
on error the error_message number the error_number
if the error_number is -128 or the error_number is -1708 then
else
display dialog "There are no unmountable volumes." buttons {"OK"} default button 1
end if
end try
else
set actiondisks to {}
set allvols to paragraphs of (do shell script "diskutil list -plist | grep -o 'disk[0-9][a-z][0-9]*'")
repeat with i in allvols
if i is not in actiondisks then
set actiondisks to actiondisks & i
end if
end repeat
repeat with myitem in actiondisks
try
do shell script "diskutil mountDisk /dev/" & myitem
end try
end repeat
end if
[kirkmc adds: I'm posting this so the final scripts can be easier to find. There were a lot of comments that helped the poster improve on his original submission, and I thank all the users who gave their thoughts on the original script, and the poster who took the time to improve it and re-post it.]