├── chain.py └── README.md /chain.py: -------------------------------------------------------------------------------- 1 | import sublime 2 | import sublime_plugin 3 | 4 | class ChainCommand(sublime_plugin.WindowCommand): 5 | def run(self, commands): 6 | window = self.window 7 | for command in commands: 8 | command_name = command[0] 9 | command_args = command[1:] 10 | window.run_command(command_name, *command_args) 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chain of Command 2 | 3 | __Sublime text plugin to run a chain of commands__ 4 | 5 | ---------- 6 | 7 | ### Usage 8 | 9 | To run a chain of commands you run the `chain` window commands and pass it a list of commands to run. Each command is defined as a list where the first argument is the name of the command to run and any additional arguments will be 10 | passed directly to the command. 11 | 12 | For example, to run the __select_all__ command and then run the __copy__ command you would call: 13 | 14 | ```python 15 | window.run_command("chain",{"commands":[["select_all"],["copy"]]}) 16 | ``` 17 | 18 | Or if you wanted to focus the first group in a window: 19 | 20 | ```python 21 | window.run_command("chain",{"commands":[["focus_group",{"group":0}]]}) 22 | ``` 23 | 24 | The point is to be able to build custom key bindings to run a sequence of commands. Lets say you wanted a key binding to duplicate the current file. You could set this key binding: 25 | 26 | ```json 27 | { 28 | "keys": ["super+shift+option+d"], 29 | "command": "chain", 30 | "args": { 31 | "commands": [ 32 | ["select_all"], 33 | ["copy"], 34 | ["new_file"], 35 | ["paste"], 36 | ["save"] 37 | ] 38 | } 39 | } 40 | ``` 41 | 42 | This would select all the text, copy it, create a new file, paste the text, then open the save file dialog. --------------------------------------------------------------------------------