Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Re-enable old style auto-save for TextEdit (with a real "Save As..."). System 10.8
While better than Lion's behavior, the lack of a true "Save As..." in Mountain Lion frustrates me. I never really saw anything wrong with the old style Autosave feature, where a temporary file gets saved periodically until you close the original file. I liked being able to edit a document and then retroactively apply all changes since the last save to a new file with a different name and location from the old file.

This is what's wrong with the "Duplicate" command, which, when it duplicates the file, includes all the changes since the last save. This forces the user to be prescient about what sorts of changes they may want to make to the file at some point in the future, whereas the old "Save As..." helpfully allows you to move all your recent changes to a different file. Unfortunately for most Apple applications, you are stuck with the new behavior. However, for TextEdit, there appears to be a way to revert to the software's Autosave and "Save As... " to that used by computers since the dawn of time.

In this hint I described how to turn off the auto-save feature for an application, which at least in TextEdit causes the true "Save As..." menu item to re-appear in the File menu and enables the Command-Shift-S shortcut to act as the real "Save As...," not "Duplicate."

When doing this however, there was one problem: the new sandboxing "feature" of OS X does not allow the old auto-save feature of TextEdit to make changes to the document's working directory, so you get annoying pop-up error messages every time TextEdit tries to make the Autosave file. Here how you can fix that.

WARNING: We will be replacing the developer's code signature for TextEdit in this hint. If you have qualms about disabling security features on your computer, stop reading here.

First, open a Terminal window and make a back-up of the application, in case we break something:

cd /Applications

ditto TextEdit.app TextEdit.backup.app


Now, we're going to use codesign to force (-f) the application to use a alternate signing identity (-s). The one we'll use is the dash (-) sign identity. This means the code will use an ad-hoc signing identity, which supposedly means that significant restrictions apply (see the man page for codesign ), but it does seem to allow TextEdit to write to a user's directory so it seems like in this case it's significantly unrestricting the app's permissions. Note that when you do this next step, it will reset the preferences for TextEdit. Also note the second dash after the dash-s, "-s-":

sudo codesign -f -s- TextEdit.app

The normal way to disable the new auto-save is the following:

defaults write com.apple.TextEdit ApplePersistence -bool no

But I couldn't get that to work. The only thing I could think of to do was get rid of the lockfile (not sure this part is needed?) and then copy TextEdit's .plist file to a directory where I could write to it, and then copy it back. Note that in this next part, I am putting a copy of the .plist lockfile and the .plist itself into root's home directory (/var/root) before doing things to them:

sudo mv /Library/Preferences/com.apple.TextEdit.plist.lockfile /var/root

sudo cp /Library/Preferences/com.apple.TextEdit.plist /var/root

sudo cp /Library/Preferences/com.apple.TextEdit.plist ~

cd ~

sudo open com.apple.TextEdit.plist


Change ApplePersistence from YES to NO. Save, and go back to the Terminal Window.

sudo mv com.apple.TextEdit.plist /Library/Preferences/

That's it! Now go enjoy your favorite text editor behaving the way it should be. This trick won't work for any other applications (e.g., Keynote); the "Save As..." menu item doesn't reappear when you disable the ApplePersistence.

[kirkmc adds: I haven't tested this. The warning at the beginning should be sufficient for anyone squeamish about trying something like this.]
  Post a comment  •  Comments (14)  
  • Currently 2.54 / 5
  You rated: 3 / 5 (13 votes cast)
 
[9,684 views]  View Printable Version
Sync calendars to an older iPod iPod
I have a perfectly serviceable 5th generation iPod nano (2009-2010). Unfortunately, every time a new major version of iTunes is released, this iPod loses part of its usability.

In an earlier hint, I showed one way to restore the ability to sync Contacts. With the release of iTunes 11, Apple has also removed the ability to sync Calendars. Under the Info tab for my nano, I now see these incorrect and misleading messages:

"No contacts are available on this computer."
"No calendars are available on this computer."

Here are two ways to remedy that situation. In Calendar, select a calendar in the sidebar, then choose File > Export > Export... and direct the output to the Calendars folder on your older iPod. Repeat this operation for all the calendars you wish to export. (File > Export > Calendar Archive... also works, but on the iPod, all events will appear under All Calendars. If you have a lot of calendars or a lot of events, this option may make it hard to navigate through.)

I tried several ways to create an AppleScript to automate the above procedure, but it turns out that Calendar is not scriptable enough to get the desired result. The script below produces an .ics file for each calendar in the sidebar, but on the iPod everything still appears under All Calendars. It would take a "real programmer" to recreate the proper export format that the manual method produces.
-- set ipodCalPath to "/Calendars/"
-- for instance:
set ipodCalPath to "/Volumes/Chris Schram’s iPod/Calendars/"

tell application "Calendar"
	
	try
		do shell script ("rm -rf " & (quoted form of ipodCalPath) & "*")
	end try
	
	delay 5 -- so Calendar is fully launched and shell script is finished
	
	set allCals to calendars
	repeat with oneCal in allCals
		set thisName to name of oneCal & ".ics"
		set thisUID to uid of oneCal
		set thisPath to (do shell script "find ~/Library/Calendars -maxdepth 2 -name " & thisUID & ".calendar") & "/Events"
		set newPath to quoted form of (ipodCalPath & thisName)
		try
			do shell script ("cat " & thisPath & "/*.ics > " & newPath)
		on error
			do shell script ("cp -rf " & thisPath & " " & newPath)
		end try
	end repeat -- with oneCal in allCals
	
	say "done exporting calendars"
	-- quit -- application "Calendar" (Optional; you choose)
	
end tell -- application "Calendar"

  Post a comment  •  Comments (1)  
  • Currently 3.00 / 5
  You rated: 4 / 5 (9 votes cast)
 
[4,909 views]  View Printable Version
Approximating iTunes DJ in iTunes 11 Apps
iTunes 11 removed iTunes DJ (neé Party Shuffle), in which it was possible to queue up a random subset of your library or of a selected playlist, and change the queue with a click of the "Refresh" button. At first it seemed as though this was gone completely, but after some fiddling it appears you can get most of the functionality back as part of the new Up Next feature.

First the basics: Starting from a playlist, just click the shuffle icon (the intersecting arrows) in the header of the playlist view, not the shuffle icon in the iTunes LCD. However, there is no shuffle icon when you view your entire music library, so you'll have to fake it by creating a smart playlist with the condition "Media kind is music," with live updating turned on.

Click list icon at the right of the iTunes LCD to view the Up Next queue. The clock icon in that list shows recently played tracks, like the dimmed portion of the old iTunes DJ interface. You can re-order songs in Up Next by dragging them around, and new items can be added to the top of the queue form anywhere in your library using the contextual menu, just like you could in iTunes 10, or by clicking the > icon that displays when you hover your cursor over a track.

What may not be obvious is how to replicate the function of the Refresh button. To do this, click the shuffle icon in the header of your playlist view again.

Now for the caveats:
  • Clicking that shuffle icon again stops the currently playing song, rather than creating a new queue as iTunes DJ did.
  • You have to click on the Up Next list icon again to see the results (or use the new Command-Option-U shortcut), rather than them being immediately visible.
  • Even with shuffle set to songs (Controls > Shuffle > By Songs), you will still see tracks from the same album show up in the list in sequence fairly often. There used to be a way to control this, but I've forgotten and can't seem to find it now.
Perhaps comments on this hint will reveal ways to overcome those issues.

[kirkmc adds: I was initially very confused by Up Next, but I've figured it out, and it's quite practical for queuing up music. However, you can only see 20 songs in the queue, which can be a bit limiting. So it's not a real replacement for iTunes DJ, and this hint does help a bit. Personally, I never used it to play music from my entire library, so the current implementation works for me.]
  Post a comment  •  Comments (13)  
  • Currently 2.67 / 5
  You rated: 1 / 5 (6 votes cast)
 
[18,222 views]  View Printable Version
Control the Finder with the Terminal UNIX
There are several ways to open a Terminal window to the current directory in the Finder. But wouldn't it be useful if you could do the reverse and open a Finder window to the current Terminal directory? Well, you can, and you can completely control the Finder from the terminal.

I have put the code on github with full instructions on how to set it up. It works by using bash_completion, .bash_profile with some applescript to control the Finder, .inputrc and .bash_aliases.

Here are some of the features:
  • Changing a directory in the Terminal opens the same directory in the Finder.
  • You can change the Finder window view from the Terminal (column, list, icon views).
  • It is case insensitve, you can press Tab for menu completion, and Shift-Tab to expand bash aliases.
  • Open a Terminal directory to the current Finder window.
This code will work with both the Terminal.app and iTerm2 and should work with older macs as well

[kirkmc adds: I haven't tested this, but it sounds very useful.]
  Post a comment  •  Comments (11)  
  • Currently 2.80 / 5
  You rated: 1 / 5 (10 votes cast)
 
[11,713 views]  View Printable Version
Display just one calendar quickly Apps
Sometimes I want to quickly disable all calendars and to display just one, for example, to see upcoming birthdays in month view.

Calendar Help says:

"To show or hide the events on all calendars, hold down the Command key while you click any calendar’s checkbox in the Calendar list."

But if you hold Command and Option, then click a calendar, you achieve exactly what I want: this hide all other calendars except the one you want to see. You can then Command-click another calendar to show them all again.
  Post a comment  •  Comments (3)  
  • Currently 3.92 / 5
  You rated: 1 / 5 (13 votes cast)
 
[5,909 views]  View Printable Version
iTunes 11: Use Up Next to play one song then stop playback Apps
The AppleScript I provided previously for this doesn't work in iTunes 11, but Up Next can be used instead.

I previously submitted this AppleScript to provide a way to play one song then stop playback in iTunes. The script doesn't work in iTunes 11, but Up Next can be used instead. Also, using this method, it can be accomplished entirely from the keyboard. (It's important to note that "All controls" must be checked at the bottom of the Keyboard Shortcuts tax tab in the Keyboard pane of System Preferences.)

The objective is to be able to select a single song in a playlist, make it start playing, then prevent playback from continuing after the song has been played in its entirety. This can be done in iTunes 11 by selecting a song to play using alternating key presses of Tab, Shift-Tab, Up Arrow and Down Arrow. The next step is most important: open the Up Next list with Command-Option-U, and check to be sure no titles appear in the list (if there are any, press Tab until the "Clear" button is highlighted, then press the spacebar to "click" that button; otherwise press Escape or Command-Option-U again to exit the list), then press Return to play the song. You can pause and resume the song with spacebar if desired, and playback will still stop at the end of the song as long as you don't add anything to the Up Next list in the meantime.

[kirkmc adds: This does seem a bit complicated, but there's no way to use AppleScript to manipulate the Up Next queue, unfortunately.]
  Post a comment  •  Comments (4)  
  • Currently 3.14 / 5
  You rated: 5 / 5 (7 votes cast)
 
[10,356 views]  View Printable Version
How to make iCloud behave like Dropbox
Local copies of files you store on iCloud are stored in the Library > Mobile Documents folder in your home folder. (See this hint for more about accessing that folder.) This can be exploited to convert iCloud into a general-purpose storage and sharing resource.

This folder in your Library folder functions exactly like the Dropbox Folder on your Mac: anything stored in it will appear in the same folder on other Macs logged onto the same iCloud account. There is no restriction on what can be placed in this folder, so the data you can store and share via iCloud is not limited to files created by Apple or Apple-approved software. When you realize this, you can use iCloud as a fully comprehensive cloud resource.

Once you have stored all the files you want in your Mobile Documents folder, to avoid having to dig around to get at it, you can access it from utilities such as the free Plain Cloud . that access your Mobile Documents folder. You can periodically update your stuff by using a folder sync application such as ChronoSync. Or, to create a more sophisticated arrangement and make it run invisibly behind the scenes, you can check out Sebastian Hallum Clarke's donation-ware utilities iClouDrive, which creates a dedicated subfolder within the Mobile Documents folder, and an aliased copy of this folder on your desktop (or wherever you choose to put it), and MacDropAny, which creates symbolic links between that aliased copy and the subfolder within Mobile Documents (and also Dropbox), so that any changes you make in your local files are instantly updated on the cloud service of your choice.
  Post a comment  •  Comments (13)  
  • Currently 2.78 / 5
  You rated: 1 / 5 (9 votes cast)
 
[23,710 views]  View Printable Version
Scripts to disable and enable password for lock screen after sleep or screen saver System

Here is two small scripts that I use to set and unset the password prompt when I lock the screen, or put my Mac to sleep. It is a nuisance to have to unlock the screen by entering the password, when at home. But I wouldn't leave my Mac anywhere without it.

I have called them setScreenPassword and unsetScreenPassword. I call them from QuickSilver, and you could use another launcher to do the same. The nifty thing about Quicksilver in this matter, is that if I activate it, I can see that I have turned on setScreenPassword, as it displays the last command before I start typing again.

I prefer to see the box in the System Preference pane get clicked, and unclicked. I have an old MacBook Pro, so I have added the delay of 0 so you can see where to add increments of 0.2 seconds, until you see the check box gets checked, or unchecked.

script EnablePasswordPrompt
	tell application "System Preferences"
		tell anchor "General" of pane "com.apple.preference.security" to reveal
		activate
	end tell
	tell application id "sevs"
		set UI elements enabled to true
		set a to value of checkbox 2 of tab group of window 1 of application process "System Preferences" as integer
		if a = 0 then
			tell checkbox 2 of tab group of window 1 of application process "System Preferences" to click
		end if
	end tell
	delay 0
	tell application "System Preferences" to quit
end script
tell EnablePasswordPrompt to run

---------------------------------------------
script disablePasswordPrompt
	tell application "System Preferences"
		tell anchor "General" of pane "com.apple.preference.security" to reveal
		activate
	end tell
	tell application id "sevs"
		set UI elements enabled to true
		set a to value of checkbox 2 of tab group of window 1 of application process "System Preferences" as integer
		if a = 1 then
			tell checkbox 2 of tab group of window 1 of application process "System Preferences" to click
		end if
	end tell
	delay 0
	tell application "System Preferences" to quit
end script
tell disablePasswordPrompt to run
  Post a comment  •  Comments (13)  
  • Currently 1.60 / 5
  You rated: 2 / 5 (5 votes cast)
 
[12,154 views]  View Printable Version
iTunes 11: Change music files to podcasts Apps
After upgrading to iTunes 11, I found it was impossible to change added files from music to podcasts.

A couple of podcasts I listen to that have subscriptions, but only one of them automatically downloads to iTunes. The other one requires me to go to the website, log in, and manually download the file.

What I then used to do was add it to iTunes by double-clicking it, then I'd stop the playback and get info on the track. I would add the show's info (which was missing), and then set it to remember playback position, skip when shuffling, and set its Media Type to Podcast. Since the Artist and Album matched the other files for that podcast, it would end up in that folder, and behave like any other podcast.

With iTunes 11, I can no longer change the file's type to Podcast. It always reverts to music. I can make it an audiobook, or any other type of media, but not a podcast.

This was annoying to say the least. So I went looking for a way to do this, and found a small free app called Typecast from Red Sweater Software.

With Typecast, you drop the mp3 file onto the app's window, enter the name of the podcast, and it sets the Media Type to podcast, and adds it to iTunes. It makes a new podcast for each file you add, even though they are the same podcast, but it shows up under the main list on my iPod, and that's what I wanted.

I don't know if this is an iTunes bug, but this is a workaround.

[kirkmc adds: Yes, it's a bug, and I assume that it will be fixed in the next update, but in the meantime, I think a lot of people will benefit from this hint.]
  Post a comment  •  Comments (5)  
  • Currently 3.40 / 5
  You rated: 3 / 5 (10 votes cast)
 
[12,180 views]  View Printable Version
How to reset Lion back to the Setup Assistant Install
There have been previous hints on how to reset earlier versions of Mac OS X to delete users so that it boots to the Setup Assistant again. This can be useful if you are passing on or selling your computer to someone else. The most recent hint was posted in 2007 for Mac OS X 10.5 and there were significant corrections included in the comments. There is also a command that changed in 10.7 (also in the older hint’s comments) and even with the modifications suggested in the comments, the hint is still incomplete.

So instead of adding yet another modification in the comments of a hint related to 10.5, I thought I would submit a new hint brining everything together from the old hint, its comments, changes needed for 10.7, and the missing items I have found. This provides a current version of the hint for 10.7 and presumably 10.8, though I have not been able to test on Mountain Lion.

1: Remove references to, and the stored passwords for, your local WiFi network.
  • In the Finder, choose Go > Utilities.
  • Open Keychain Access in the Utilities folder.
  • If you don’t have a list of keychains on the left, choose View > Show Keychains.
  • On the keychains list on the left, select the System keychain. There should be an AirPort network password item in the list for your local WiFi network. Select it and press Delete. Confirm that you want to delete the item and quit Keychain Access.
  • Go to System Preferences > Network
  • Select Wi-Fi from the list on the left and click the Advanced button on the bottom right.
  • In the‘Preferred Networks: list, select your network and click the minus button below the list.
  • Click OK and then Apply button in the main Network Preferences window.
  • Click Turn Wi-Fi Off, then click it again to turn Wi-Fi back on. It should not connect to your network anymore (and should ask for a password if you try).
2: Still in System Preferences, click Show All at the top left and then click the Users & Groups icon. Delete all users except for the one you are currently logged in as. In the rest of this hint, this remaining user will be referred to as USERNAME.

3: Boot your Mac into single user mode by restarting and holding down Command-S at startup.

4: Mount the filesystem in write mode and delete the USERNAME home directory.
$ mount -uw /
$ rm -R /Users/USERNAME/


5: Load OpenDirectory so we can remove the system’s record of USERNAME.
$ launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

6: Find the UID of USERNAME.
$ dscl . -read /Users/USERNAME GeneratedUID
In the next step, type in this UID where you see GENERATEDUID written.

7: Remove USERNAME from the systemwide admin group and then remove USERNAME’s record.
$ dscl . -delete /Groups/admin GroupMembers GENERATEDUID
$ dscl . -delete /Groups/admin GroupMembership USERNAME
$ dscl . -delete /Users/USERNAME


8: Remove the Setup Assistant flag so that it runs when the Mac is started up.
$ rm /var/db/.AppleSetupDone

9:[optional] Remove the cache files and virtual memory swapfile.
$ rm -R /Library/Caches/*
$ rm -R /var/vm/swapfile*


10: $ shutdown -h now

If you want to check that the Setup Assistant will run, you can turn on your Mac. When the Setup Assistant starts, just press cmd-Q on the keyboard and you will be prompted to shut down. Your Mac has been reset.

[kirkmc adds: I'm running this hint because it contains a lot of useful information. But I wonder why one can't simply erase the hard disk and re-run the installer to get everything back to its initial state. That seems a lot easier to me…]
  Post a comment  •  Comments (18)  
  • Currently 2.87 / 5
  You rated: 1 / 5 (15 votes cast)
 
[42,050 views]  View Printable Version