├── .gitignore ├── CHANGELOG.md ├── Commands.sublime-commands ├── Main.sublime-menu ├── README.md ├── UNLICENSE ├── edit_command_palette.py ├── messages.json ├── messages └── install.md └── symlink.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # sublime-edit-command-palette changelog 2 | 2.1.0 - Repaired opening User commands on Windows. Fixed #2 3 | 4 | 2.0.1 - Updated `install.md` to have `README.md's` rename changes 5 | 6 | 2.0.0 - Renamed from `sublime-commands` to `sublime-edit-command-palette` to appease Package Control maintainers 7 | 8 | 1.3.0 - Added `commands_open_file` to open a commands file with desired syntax 9 | 10 | 1.2.0 - Moved `default_prompt.json` into plugin to avoid ST3 packaging issues 11 | 12 | 1.1.0 - Fixed up Windows, ST3, and documentation issues for Package Control submission 13 | 14 | 1.0.0 - Initial release 15 | -------------------------------------------------------------------------------- /Commands.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences: Commands - Default", 4 | "command": "edit_command_palette_open_file", 5 | "args": { 6 | "file": "${packages}/Default/Default.sublime-commands" 7 | } 8 | }, 9 | { 10 | "caption": "Preferences: Commands - User", 11 | "command": "edit_command_palette_open_user" 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences", 4 | "mnemonic": "n", 5 | "id": "preferences", 6 | "children": 7 | [ 8 | {"caption": "-"}, 9 | { 10 | "caption": "Commands – Default", 11 | "command": "edit_command_palette_open_file", 12 | "args": { 13 | "file": "${packages}/Default/Default.sublime-commands" 14 | } 15 | }, 16 | { 17 | "caption": "Commands – User", 18 | "command": "edit_command_palette_open_user" 19 | }, 20 | {"caption": "-"} 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sublime-edit-command-palette 2 | 3 | Add/edit commands for your Command Palette 4 | 5 | This plugin was created out of frustration that multiple plugin creators write key bindings but nothing for the command palette. 6 | 7 | ![Animation](https://cloud.githubusercontent.com/assets/902488/4873073/c09b61c2-6200-11e4-8d1c-f149558ef04c.gif) 8 | 9 | ## Getting Started 10 | ### Installation 11 | This package is available under `Edit Command Palette` inside of [Package Control][], a [Sublime Text][] plugin that allows for easy management of other plugins. 12 | 13 | [Sublime Text]: http://www.sublimetext.com/ 14 | [Package Control]: http://wbond.net/sublime_packages/package_control 15 | 16 | If you prefer the manual route, you can install the script via the following command in the Sublime Text terminal (``ctrl+` ``) which utilizes `git clone`. 17 | 18 | ```python 19 | import os; path=sublime.packages_path(); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/twolfson/sublime-edit-command-palette', 'Edit Command Palette'], 'working_dir': path}) 20 | ``` 21 | 22 | Packages can be uninstalled via "Package Control: Remove Package" via the command pallete, `ctrl+shift+p` on Windows/Linux, `command+shift+p` on Mac. 23 | 24 | ### Command Palette 25 | `sublime-edit-command-palette` provides 2 commands to access Sublime Text's commands: 26 | 27 | - `Preferences: Commands - Default` - Opens default commands provided by Sublime Text 28 | - `Preferences: Commands - User` - Opens custom user commands and provides prompt for first-timers 29 | 30 | ### Menu 31 | `sublime-edit-command-palette` defines 2 menu items under `Preferences`: 32 | 33 | - `Commands - Default` - Opens default commands provided by Sublime Text 34 | - `Commands - User` - Opens custom user commands and provides prompt for first-timers 35 | 36 | ## Documentation 37 | ### `edit_command_palette_open_user(self)` 38 | `edit_command_palette_open_user` creates a default `Packages/User/Default.sublime-commands` containing a prompt for the user, opens it, and sets the language to JSON. 39 | 40 | We add in the default and language to make it more approachable. Otherwise, it would be an empty file and in plain text by default. 41 | 42 | ## Contributing 43 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. 44 | 45 | ## Donating 46 | Support this project and [others by twolfson][gratipay] via [gratipay][]. 47 | 48 | [![Support via Gratipay][gratipay-badge]][gratipay] 49 | 50 | [gratipay-badge]: https://cdn.rawgit.com/gratipay/gratipay-badge/2.x.x/dist/gratipay.png 51 | [gratipay]: https://www.gratipay.com/twolfson/ 52 | 53 | ## Unlicense 54 | As of Oct 31 2014, Todd Wolfson has released this repository and its contents to the public domain. 55 | 56 | It has been released under the [UNLICENSE][]. 57 | 58 | [UNLICENSE]: UNLICENSE 59 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /edit_command_palette.py: -------------------------------------------------------------------------------- 1 | from os import path 2 | import sublime 3 | import sublime_plugin 4 | 5 | # Define dictionary for path constants and default content 6 | C = {} 7 | DEFAULT_CONTENT = """[ 8 | // Define your custom Sublime commands here 9 | // Format is same as `key bindings` except replace `keys` with `caption` 10 | // { 11 | // // Name to show in Command Palette 12 | // "caption": "File: New", 13 | // // Command to invoke 14 | // "command": "new_file", 15 | // // Optional keyword arguments to provide to command 16 | // "args": {"key": "value"} 17 | // } 18 | ]""" 19 | 20 | 21 | def plugin_loaded(): 22 | """Once the plugin has loaded, define constants""" 23 | C['SUBLIME_ROOT'] = path.normpath(path.join(sublime.packages_path(), '..')) 24 | C['COMMANDS_FILEPATH'] = path.join('Packages', 'User', 'Default.sublime-commands') 25 | C['COMMANDS_SUBLIME_FILEPATH'] = '${packages}/User/Default.sublime-commands' 26 | C['COMMANDS_FULL_FILEPATH'] = path.join(C['SUBLIME_ROOT'], C['COMMANDS_FILEPATH']) 27 | 28 | 29 | class EditCommandPaletteOpenFileCommand(sublime_plugin.WindowCommand): 30 | def run(self, file): 31 | """Open a commands file with default JSON syntax""" 32 | # Open the commands file 33 | # DEV: We use this because `${packages}` is not easy to resolve in ST3 34 | self.window.run_command('open_file', { 35 | 'file': file, 36 | }) 37 | 38 | # If the syntax is plain text, move to JSON 39 | # DEV: Syntax paths always use `/`, even on Windows via https://github.com/wbond/package_control_channel/pull/3780#issuecomment-61369387 40 | view = self.window.active_view() 41 | if view.settings().get('syntax') == 'Packages/Text/Plain text.tmLanguage': 42 | view.set_syntax_file('Packages/JavaScript/JSON.tmLanguage') 43 | 44 | 45 | class EditCommandPaletteOpenUserCommand(sublime_plugin.WindowCommand): 46 | def run(self): 47 | """Open `Packages/User/Default.sublime-commands` for custom definitions""" 48 | # If the User commands doesn't exist, provide a prompt 49 | filepath = C['COMMANDS_FULL_FILEPATH'] 50 | if not path.exists(filepath): 51 | with open(filepath, 'w') as f: 52 | f.write(DEFAULT_CONTENT) 53 | 54 | # Open the commands file 55 | self.window.run_command('edit_command_palette_open_file', { 56 | 'file': C['COMMANDS_SUBLIME_FILEPATH'], 57 | }) 58 | 59 | 60 | # If we are not in ST3, run `plugin_loaded` by default 61 | if sublime.version() < '3000': 62 | plugin_loaded() 63 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.md" 3 | } -------------------------------------------------------------------------------- /messages/install.md: -------------------------------------------------------------------------------- 1 | # sublime-edit-command-palette 2 | 3 | Add/edit commands for your Command Palette 4 | 5 | This plugin was created out of frustration that multiple plugin creators write key bindings but nothing for the command palette. 6 | 7 | ## Getting Started 8 | ### Command Palette 9 | `sublime-edit-command-palette` provides 2 commands to access Sublime Text's commands: 10 | 11 | - `Preferences: Commands - Default` - Opens default commands provided by Sublime Text 12 | - `Preferences: Commands - User` - Opens custom user commands and provides prompt for first-timers 13 | 14 | ### Menu 15 | `sublime-edit-command-palette` defines 2 menu items under `Preferences`: 16 | 17 | - `Commands - Default` - Opens default commands provided by Sublime Text 18 | - `Commands - User` - Opens custom user commands and provides prompt for first-timers 19 | 20 | ## Documentation 21 | ### `edit_command_palette_open_user(self)` 22 | `edit_command_palette_open_user` creates a default `Packages/User/Default.sublime-commands` containing a prompt for the user, opens it, and sets the language to JSON. 23 | 24 | We add in the default and language to make it more approachable. Otherwise, it would be an empty file and in plain text by default. 25 | 26 | ## Contributing 27 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. 28 | 29 | ## Donating 30 | Support this project and others by twolfson via gratipay. 31 | 32 | https://www.gratipay.com/twolfson/ 33 | 34 | ## Unlicense 35 | As of Oct 31 2014, Todd Wolfson has released this repository and its contents to the public domain. 36 | 37 | It has been released under the [UNLICENSE][]. 38 | 39 | [UNLICENSE]: ../UNLICENSE 40 | -------------------------------------------------------------------------------- /symlink.sh: -------------------------------------------------------------------------------- 1 | ln -s $PWD ~/.config/sublime-text-3/Packages/Commands 2 | --------------------------------------------------------------------------------