docs » Commander

This spoon lets execute commands from other spoon by a chooser.

The way of Commander to generate it command list is it goes to each spoon and extract all public functions inside the spoon table. for each function the name is set to "spoonName.functionName". if the spoon has a table called commandderCommandTable, Commander will ignore everything else and take whatever is in the table. In this case the naming convention is the same. Then Commander grabs all the functions in global table. functions are tested against Commander.ignoredCommandList, except when spoon author provides a commanderCommandList.

Commander.chooser is the chooser, you can set background color, rows, etc, to it.

API Overview

API Documentation

Variables

commandTable
Signature Commander.commandTable
Type Variable
Description This is the table which stores all the commands
Notes
  • Each key is the name of the command, and each value is the actual function. You can add your custom commands to it.
Source Source/Commander.spoon/init.lua line 33
forceLayout
Signature Commander.forceLayout
Type Variable
Description If you want to switch to a layout when enabled chooser, set this to name of that layout
Source Source/Commander.spoon/init.lua line 54
forceMethod
Signature Commander.forceMethod
Type Variable
Description If you want to switch to a method when enabled chooser, set this to name of that method
Source Source/Commander.spoon/init.lua line 59
ignoredCommandList
Signature Commander.ignoredCommandList
Type Variable
Description This list contains all the ignored function names, any function matches the name inside this list will not be added to Commander.commandTable.
Notes
  • The list contains normal lua builtin functions and some hammerspoon functions that generally shouldn't be a command, such as init, bindHotkeys, etc.
Source Source/Commander.spoon/init.lua line 41

Functions

addCommand
Signature Commander.addCommand(commandTable)
Type Function
Description Add a command to Commander.commandTable
Parameters
  • commandTable - It is a table with same form of Commander.commandTable key is name of command, value is the function.
Returns
Notes
  • Commander doesn't test the name against Commander.ignoredCommandList because it assumes you know what you are doing.
Source Source/Commander.spoon/init.lua line 124
resetCommandTable
Signature Commander.resetCommandTable()
Type Function
Description This function simply set Commander.commandTable to {}, then the next time commander chooser is called it will generate the table again.
Parameters
  • None
Returns
Source Source/Commander.spoon/init.lua line 137
show
Signature Commander.show()
Type Function
Description This function shows the command chooser. Bind this to a hotkey to use commander.
Parameters
  • None
Returns
Source Source/Commander.spoon/init.lua line 64