|
| 1 | +# Custom Commands in Crush |
| 2 | + |
| 3 | +Crush supports custom commands (sometimes called saved prompts) that can be |
| 4 | +created by users to quickly send predefined prompts to the AI assistant. |
| 5 | + |
| 6 | +## Creating Custom Commands |
| 7 | + |
| 8 | +Custom commands are predefined prompts stored as Markdown files in one of three |
| 9 | +locations: |
| 10 | + |
| 11 | +1. User Commands: |
| 12 | + |
| 13 | + ```bash |
| 14 | + # Unix-like systems (Linux, macOS, FreeBSD, etc.) |
| 15 | + $XDG_CONFIG_HOME/crush/commands/ |
| 16 | + |
| 17 | + # Windows |
| 18 | + %USERPROFILE%\AppData\Local\crush\commands\ |
| 19 | + ``` |
| 20 | + |
| 21 | +2. Project Commands: |
| 22 | + |
| 23 | + ```bash |
| 24 | + <PROJECT DIR>/.crush/commands/ |
| 25 | + ``` |
| 26 | + |
| 27 | +Each Markdown file in these directories becomes a custom command. The file name |
| 28 | +(without the extension) becomes the name of the command. |
| 29 | + |
| 30 | +For example, creating a file at `~/.config/crush/commands/carrot-cake.md` with |
| 31 | +the following content: |
| 32 | + |
| 33 | +```markdown |
| 34 | +RUN git ls-files |
| 35 | +READ README.md |
| 36 | +``` |
| 37 | + |
| 38 | +...creates a command called `user:carrot-cake`. |
| 39 | + |
| 40 | +### Command Arguments |
| 41 | + |
| 42 | +Crush supports named arguments in custom commands using placeholders in the |
| 43 | +format `$NAME` (where NAME consists of uppercase letters, numbers, and |
| 44 | +underscores, and must start with a letter). |
| 45 | + |
| 46 | +For example: |
| 47 | + |
| 48 | +```markdown |
| 49 | +# Fetch Context for Issue $ISSUE_NUMBER |
| 50 | + |
| 51 | +RUN gh issue view $ISSUE_NUMBER --json title,body,comments |
| 52 | +RUN git grep --author="$AUTHOR_NAME" -n . |
| 53 | +RUN grep -R "$SEARCH_PATTERN" $DIRECTORY |
| 54 | +``` |
| 55 | + |
| 56 | +When you run a command with arguments, crush will prompt you to enter values |
| 57 | +for each unique placeholder. |
| 58 | + |
| 59 | +### Organizing Commands |
| 60 | + |
| 61 | +Commands can be organized into sub-directories: |
| 62 | + |
| 63 | +``` |
| 64 | +~/.config/crush/commands/git/commit.md |
| 65 | +``` |
| 66 | + |
| 67 | +This creates a command with ID `user:git:commit`. |
| 68 | + |
| 69 | +### Using Custom Commands |
| 70 | + |
| 71 | +1. Press <kbd>Ctrl+p</kbd> to open the command dialog |
| 72 | +2. Press <kbd>Tab</kbd> to switch to User Commands |
| 73 | +3. Select your custom command |
0 commit comments