|
| 1 | +# Custom Commands (aka saved prompts) in Crush |
| 2 | + |
| 3 | +Crush supports custom commands that can be created by users to quickly send |
| 4 | +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 (without the extension) becomes the name of the command. |
| 28 | + |
| 29 | +For example, creating a file at `~/.config/crush/commands/carrot-cake.md` with content: |
| 30 | + |
| 31 | +```markdown |
| 32 | +RUN git ls-files |
| 33 | +READ README.md |
| 34 | +``` |
| 35 | + |
| 36 | +This creates a command called `user:carrot-cake`. |
| 37 | + |
| 38 | +### Command Arguments |
| 39 | + |
| 40 | +Crush supports named arguments in custom commands using placeholders in the format `$NAME` (where NAME consists of uppercase letters, numbers, and underscores, and must start with a letter). |
| 41 | + |
| 42 | +For example: |
| 43 | + |
| 44 | +```markdown |
| 45 | +# Fetch Context for Issue $ISSUE_NUMBER |
| 46 | + |
| 47 | +RUN gh issue view $ISSUE_NUMBER --json title,body,comments |
| 48 | +RUN git grep --author="$AUTHOR_NAME" -n . |
| 49 | +RUN grep -R "$SEARCH_PATTERN" $DIRECTORY |
| 50 | +``` |
| 51 | + |
| 52 | +When you run a command with arguments, crush will prompt you to enter values for each unique placeholder. |
| 53 | + |
| 54 | +### Organizing Commands |
| 55 | + |
| 56 | +You can organize commands in subdirectories: |
| 57 | + |
| 58 | +``` |
| 59 | +~/.config/crush/commands/git/commit.md |
| 60 | +``` |
| 61 | + |
| 62 | +This creates a command with ID `user:git:commit`. |
| 63 | + |
| 64 | +### Using Custom Commands |
| 65 | + |
| 66 | +1. Press <kbd>Ctrl+p</kbd> to open the command dialog |
| 67 | +2. Press <kbd>Tab</kbd> to switch to User Commands |
| 68 | +3. Select your custom command |
0 commit comments