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

10.7: Scripting a fix for the loss of the Command+D shortcut Apps
I do a lot of writing with TextEdit, using a keyboard shortcut with the macro editor QuicKeys. My SL macro would switch to or open TextEdit, close any previous TextEdit document using the built-in Mac keyboard shortcut Command+D (which closes a window without saving). Lion has evidently done away with the Command+D shortcut, so my macro wouldn't work. Here is a simple script that opens or switches to TextEdit, closes (without saving) any note that is there, and opens a new note:
tell application "TextEdit"
  activate
  try
    close window 1 saving no
  end try
  make new document  
end tell
This can be entered in QuicKeys and activated with the keyboard shortcut of your choosing.

[crarko adds: I suppose the removal of Command+D is a result of the new Auto Save feature; things get saved whether you intend it or not.]
    •    
  • Currently 3.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[4,574 views]  

10.7: Scripting a fix for the loss of the Command+D shortcut | 13 comments | Create New Account
Click here to return to the '10.7: Scripting a fix for the loss of the Command+D shortcut' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: DougAdams on Jul 22, '11 07:48:45AM

The Command-D shortcut brings to Desktop to the front in the Open Save dialog.

---
dougscripts.com



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: aptenergy on Jul 22, '11 08:17:07AM

Command-Delete is the replacement keyboard command.



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: ridogi on Jul 22, '11 08:20:09AM

Command backspace is the new shortcut for don't save in Lion.



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: Lri on Jul 22, '11 08:21:29AM

You can now use ⌘⌫ (delete / backspace) for Don't Save in Lion, see http://mattgemmell.com/2011/07/21/save-sheet-shortcuts-in-lion. ⌘D is already used an alternative shortcut for ⇧⌘D in file dialogs.

I've been using this script for a while:

try
	tell application (path to frontmost application as text)
		set a to do shell script "echo " & quoted form of (path to it as text) & " | sed 's/.*:\\(.*\\).app:/\\1/'"
		if {"TextMate"} contains a then
			close window 1
			tell application "System Events" to key code 51 using command down -- keystroke "d" in 10.6
		else
			close window 1 saving no
		end if
		if (count (windows where visible is true)) is 0 then
			tell application "System Events" to keystroke tab using option down
			-- ⌥⇥ = Move Focus to Active or Next Window
		end if
	end tell
end try


[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: onefoot17 on Jul 22, '11 08:25:52AM

They changed the shortcut to Command-Delete, if that helps. http://daringfireball.net/linked/2011/07/21/save-sheet-shortcuts



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: mr. applescript on Jul 22, '11 09:19:15AM
Hmmm. I wonder if you can get the name of the frontmost application by just asking for it?
tell application (path to frontmost application as text)
	set a to the name of it
end tell


[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: stereoscott on Jul 22, '11 12:27:13PM

Good hint. Just wanted to point out that at some point your fingers might accidentally hit cmd-d instead of cmd-s and you'll end up losing some work (hopefully not much given the auto-save feature). If you don't mind using two hands, I think cmd-delete (the default) is a wiser choice conceptually and physically.



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: xcgr on Jul 23, '11 09:03:38AM

The "Dont' Save" keyboard shortcut didn't go away. It was just changed to Command-Delete.



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: arcticmac on Jul 25, '11 05:40:50PM

Someone suggested another method involving the "defaults" command this morning on macrumors. Don't know if it's actually the same thing or not (no lion for me yet), but worth looking at:
http://www.macrumors.com/2011/07/25/making-lion-act-more-like-snow-leopard/

Edited on Jul 25, '11 05:41:34PM by arcticmac


[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: Cantus on Jul 26, '11 02:46:10AM

Just type the following in the Terminal:

defaults write NSGlobalDomain NSSavePanelStandardDesktopShortcutOnly -bool YES

Courtesy of MacRumors.com.



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: kirkmc on Jul 26, '11 02:51:12AM

This is inconsistent. Only some Apple apps have gotten rid of Command-D. It still works in Mail, but not in other apps that I've found yet.

In most other apps, however, Command-D still works, and Command-Delete doesn't.

---
Read my blog: Kirkville -- http://www.mcelhearn.com
Author of Take Control of iTunes 10: The FAQ and Take Control of Scrivener 2



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: ccstone on Jul 26, '11 07:17:38AM

In Lion's TextEdit Command-Delete replaces Command-D to close without saving. I expect this keyboard shortcut will eventually become an application standard.

-ccs



[ Reply to This | # ]
10.7: Scripting a fix for the loss of the Command+D shortcut
Authored by: thefferon on Nov 01, '11 08:22:09PM

I am square in the camp that regrets the move away from command-D for Don't Save in TextEdit.

Some people appear not to understand the objection - it's not that there is not another shortcut (i.e., command-delete) to do what we want, but that the old shortcut was perfect, it's ingrained in our brains, we used it all the time, and we would like to at least have the option of using it if we want to. If we lose a document now and then because we hit command-D instead of command-S (not likely - hmm, it never happened before, and we used it every day) then we have no one to blame but ourselves for restoring the shortcut. The fact that this post exists (and many more like it) indicates there are a LOT of people who object to the removal of a favorite useful shortcut.

The Terminal command posted here (and elsewhere) worked on 10.7.1, but someone at Apple decided that Apple really does know best, and they broke it with 10.7.2. Here's hoping there is someone out there who knows the ins and outs of the OS enough and that they post a new hack.

Again, it's not that we want to get used to the new one, it's that we want the old one back, or at least have the choice.



[ Reply to This | # ]