docs » ClipboardTool

Keep a history of the clipboard for text entries and manage the entries with a context menu

Originally based on TextClipboardHistory.spoon by Diego Zamboni with additional functions provided by a context menu and on code by VFS, but with many changes and some contributions and inspiration from asmagill.

Download: https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ClipboardTool.spoon.zip

API Overview

API Documentation

Variables

deduplicate
Signature ClipboardTool.deduplicate
Type Variable
Description

Whether to remove duplicates from the list, keeping only the latest one. Defaults to true.

Source Source/ClipboardTool.spoon/init.lua line 90
display_max_length
Signature ClipboardTool.display_max_length
Type Variable
Description

Number of characters to which each clipboard item will be truncated, when displaying in the menu. This only truncates in display, the full content will be used for searching and for pasting.

Source Source/ClipboardTool.spoon/init.lua line 105
frequency
Signature ClipboardTool.frequency
Type Variable
Description

Speed in seconds to check for clipboard changes. If you check too frequently, you will degrade performance, if you check sparsely you will loose copies. Defaults to 0.8.

Source Source/ClipboardTool.spoon/init.lua line 23
hist_size
Signature ClipboardTool.hist_size
Type Variable
Description

How many items to keep on history. Defaults to 100

Source Source/ClipboardTool.spoon/init.lua line 28
honor_ignoredidentifiers
Signature ClipboardTool.honor_ignoredidentifiers
Type Variable
Description

If true, check the data identifiers set in the pasteboard and ignore entries which match those listed in ClipboardTool.ignoredIdentifiers. The list of identifiers comes from http://nspasteboard.org. Defaults to true

Source Source/ClipboardTool.spoon/init.lua line 48
ignoredIdentifiers
Signature ClipboardTool.ignoredIdentifiers
Type Variable
Description

Types of clipboard entries to ignore, see http://nspasteboard.org. Code from https://github.com/asmagill/hammerspoon-config/blob/master/utils/_menus/newClipper.lua.

Notes
  • Default value (don't modify unless you know what you are doing):
 {
    ["de.petermaurer.TransientPasteboardType"] = true, -- Transient : Textpander, TextExpander, Butler
    ["com.typeit4me.clipping"]                 = true, -- Transient : TypeIt4Me
    ["Pasteboard generator type"]              = true, -- Transient : Typinator
    ["com.agilebits.onepassword"]              = true, -- Confidential : 1Password
    ["org.nspasteboard.TransientType"]         = true, -- Universal, Transient
    ["org.nspasteboard.ConcealedType"]         = true, -- Universal, Concealed
    ["org.nspasteboard.AutoGeneratedType"]     = true, -- Universal, Automatic
 }
Source Source/ClipboardTool.spoon/init.lua line 63
logger
Signature ClipboardTool.logger
Type Variable
Description

Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.

Source Source/ClipboardTool.spoon/init.lua line 58
max_entry_size
Signature ClipboardTool.max_entry_size
Type Variable
Description

maximum size of a text entry

Source Source/ClipboardTool.spoon/init.lua line 33
max_size
Signature ClipboardTool.max_size
Type Variable
Description

Whether to check the maximum size of an entry. Defaults to false.

Source Source/ClipboardTool.spoon/init.lua line 38
paste_on_select
Signature ClipboardTool.paste_on_select
Type Variable
Description

Whether to auto-type the item when selecting it from the menu. Can be toggled on the fly from the chooser. Defaults to false.

Source Source/ClipboardTool.spoon/init.lua line 53
show_copied_alert
Signature ClipboardTool.show_copied_alert
Type Variable
Description

If true, show an alert when a new item is added to the history, i.e. has been copied.

Source Source/ClipboardTool.spoon/init.lua line 43
show_in_menubar
Signature ClipboardTool.show_in_menubar
Type Variable
Description

Whether to show a menubar item to open the clipboard history. Defaults to true

Source Source/ClipboardTool.spoon/init.lua line 95

Methods

bindHotkeys
Signature ClipboardTool:bindHotkeys(mapping)
Type Method
Description

Binds hotkeys for ClipboardTool

Parameters
  • mapping - A table containing hotkey objifier/key details for the following items:
    • show_clipboard - Display the clipboard history chooser
    • toggle_clipboard - Show/hide the clipboard history chooser
Returns
Source Source/ClipboardTool.spoon/init.lua line 482
checkAndStorePasteboard
Signature ClipboardTool:checkAndStorePasteboard()
Type Method
Description

If the pasteboard has changed, we add the current item to our history and update the counter

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 382
clearAll
Signature ClipboardTool:clearAll()
Type Method
Description

Clears the clipboard and history

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 177
clearLastItem
Signature ClipboardTool:clearLastItem()
Type Method
Description

Clears the last added to the history

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 190
pasteboardToClipboard
Signature ClipboardTool:pasteboardToClipboard(item)
Type Method
Description

Add the given string to the history

Parameters
  • item - string to add to the clipboard history
Returns
  • None
Source Source/ClipboardTool.spoon/init.lua line 218
shouldBeStored
Signature ClipboardTool:shouldBeStored()
Type Method
Description

Verify whether the pasteboard contents matches one of the values in ClipboardTool.ignoredIdentifiers

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 342
showClipboard
Signature ClipboardTool:showClipboard()
Type Method
Description

Display the current clipboard list in a chooser

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 452
start
Signature ClipboardTool:start()
Type Method
Description

Start the clipboard history collector

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 426
toggleClipboard
Signature ClipboardTool:toggleClipboard()
Type Method
Description

Show/hide the clipboard list, depending on its current state

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 468
togglePasteOnSelect
Signature ClipboardTool:togglePasteOnSelect()
Type Method
Description

Toggle the value of ClipboardTool.paste_on_select

Parameters
  • None
Returns
Source Source/ClipboardTool.spoon/init.lua line 132