Newbie question, Clipboard history is great, is there a way to reverse sort the entries?


Newbie here. I really like the clipboard history. I use it all the time, however I would love to be able to see my history in reverse sort (oldest first - date modified) rather than the current (newest first - date modified). Is this possible?

Thanks in advance

Maybe you know this, (I can't tell if you already know this) but if you press the "End" key, it will take you to the end and the oldest is visible at the bottom. This is not exactly what you want, but it's pretty similar to what you want.

Thank you Airy for your great suggestion.

I was hoping / looking for more of a view change rather than an individual selection. a sort by oldest would allow me to view / select / export a selection of notes as I read them rather than in reverse.

My other option would be to export then find another app to reverse the order but I was hoping I could do this within KM itself.

Thanks again

AFAIK you can't change the view, nor can you "reverse merge" the entries.

What you can do, however, is "promote" historical entries to the System Clipboard -- do that in the right order and you'll have your reversed list of entries, albeit at the top of the list and with reset timestamps. And since this is KM, you can do it with a macro!

See if this gets close to what you want:

Clipboard History Reverse.kmmacros (3.5 KB)

1 Like


You are a genius, my friend. Problem solved!!!



I learn something from him every day, like that macro he just gave you. Pretty smart of him.


Side note here, but the sort of hidden built-in system shortcut for navigating to the top/bottom of a list is Option-[Up Arrow/Down Arrow]. This works most everywhere—Finder list views, Mail mailboxes, the Keyboard Maestro Groups column, the menus of an app, etc., etc., etc.

Edit: This is in contrast to the End key which will often just shift the view of a list, like scrolling to the top/bottom without changing what is selected.

Another couple of footnotes:

  1. The maximum number of past clipboard items seems to default to 200, and is otherwise settable or retrievable at the command line, but
  2. I notice that reversing a large sequence of past items in this way seems to hit some kind of resource or timing bottleneck, and skips or errors a little at intervals (here) of around 25 items.

manual:Preferences:Clipboard [Keyboard Maestro Wiki]

defaults write com.stairways.keyboardmaestro.engine MaxClipboardHistory -int 200


No – looking at the Engine.log, I think point 2 is my misunderstanding – je ne suis plus de mon avis – I was probably specifying a range beyond the actual number of items currently in my clipboard history.

(the bottleneck was just in the notifications system's capacity to continually report a sequence of errors)

Is there a way of obtaining the count of items currently in the history (distinct from the MaxClipboardHistory maximum capacity) ?

Hi everyone: Version 1.1 updated question

With the script I am currently manually counting the numbered item which clipboard items I want to reverse, which is fine for a few items or contiguous items.

But what if I have many items? What if they are not contiguous like a range. Example: 3, 5-9, 11-15

Are there ways where KM can tell me which item it is or have it give me me its number or use selection instead?

Is there a way to select the items and somehow use selection instead of numbers or a more automated way of getting the list or groups of numbers of items I need?

Thanks in advance,

I did look when doing the macro, but couldn't find a way of getting the current selection.

Counting? Click the "Show Information" button at the top of the window, then you'll see the clipboard numbers (my apologies for not mentioning that -- I didn't know they could be hidden!).

If you want a non-contiguous range, use a single field in the prompt and enter the ranges as you did above. You can then split that value into "chunks" and process those in order, as either ranges or individual items:

Clipboard History Reverse v2.kmmacros (6.0 KB)


Work through the actions to see what's going on, and there's anything you don't understand then ask.

Note that, because you are "bubbling up" past clipboards and changing their indexes, trying to promote a more recent item after you've moved older clipboards won't work. So you can't do 3-5,1 for example. Getting round that is an "exercise for the reader" :wink:

1 Like

Just what I needed. Learning by example and apprenticeship. You are awesome!!!


And how wrong I was...

You can -- but you have to bounce out to System Events. And since, when accessed in that way, the clipboard entries don't appear to have an "index" property, you have to work down the full list to find a match and generate your own index.

This is the most efficient way I found, but I'm hoping others can improve on the general idea. It takes longer to do the actual "shuffling", but IMO that's worth it for avoiding the prompt and potential data entry errors.

Clipboard History Reverse v3.kmmacros (3.9 KB)


The macro's AppleScript
set theList to {}

tell application "System Events"
	tell process "Keyboard Maestro Engine"
		set theWindow to item 1 of (get every window whose name is "Clipboard History Switcher")
		tell scroll area 1 of group 1 of theWindow
			set maxCount to count of (get every group)
			set selectedItems to every group whose selected is true
			set i to 1
			repeat with eachItem in selectedItems
				repeat while i ≤ maxCount
					if contents of eachItem = (get group i) then
						copy (i - 1) to end of theList
						set i to i + 1
						exit repeat
						set i to i + 1
					end if
				end repeat
			end repeat
		end tell
	end tell
end tell

set AppleScript's text item delimiters to ","
return theList as text