surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| 1 | #!/bin/bash |
| 2 | # Frontmatter Parser Utility |
| 3 | # Extracts YAML frontmatter from .local.md files |
| 4 | |
| 5 | set -euo pipefail |
| 6 | |
| 7 | # Usage |
| 8 | show_usage() { |
| 9 | echo "Usage: $0 <settings-file.md> [field-name]" |
| 10 | echo "" |
| 11 | echo "Examples:" |
| 12 | echo " # Show all frontmatter" |
| 13 | echo " $0 .claude/my-plugin.local.md" |
| 14 | echo "" |
| 15 | echo " # Extract specific field" |
| 16 | echo " $0 .claude/my-plugin.local.md enabled" |
| 17 | echo "" |
| 18 | echo " # Extract and use in script" |
| 19 | echo " ENABLED=\$($0 .claude/my-plugin.local.md enabled)" |
| 20 | exit 0 |
| 21 | } |
| 22 | |
| 23 | if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then |
| 24 | show_usage |
| 25 | fi |
| 26 | |
| 27 | FILE="$1" |
| 28 | FIELD="${2:-}" |
| 29 | |
| 30 | # Validate file |
| 31 | if [ ! -f "$FILE" ]; then |
| 32 | echo "Error: File not found: $FILE" >&2 |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | # Extract frontmatter |
| 37 | FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$FILE") |
| 38 | |
| 39 | if [ -z "$FRONTMATTER" ]; then |
| 40 | echo "Error: No frontmatter found in $FILE" >&2 |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | # If no field specified, output all frontmatter |
| 45 | if [ -z "$FIELD" ]; then |
| 46 | echo "$FRONTMATTER" |
| 47 | exit 0 |
| 48 | fi |
| 49 | |
| 50 | # Extract specific field |
| 51 | VALUE=$(echo "$FRONTMATTER" | grep "^${FIELD}:" | sed "s/${FIELD}: *//" | sed 's/^"\(.*\)"$/\1/' | sed "s/^'\\(.*\\)'$/\\1/") |
| 52 | |
| 53 | if [ -z "$VALUE" ]; then |
| 54 | echo "Error: Field '$FIELD' not found in frontmatter" >&2 |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | echo "$VALUE" |
| 59 | exit 0 |