Manik
LinenCharcoalDenimPlumMossButterBlushSkyEspresso
Default FontSource SerifInconsolata

rex

Auto-discover your local scripts and run them as a structured CLI.

HomebrewShell

macOS & Linux

Rex πŸ¦–

Rex is a CLI tool that auto-discovers executable scripts from configured directories and exposes them as a structured command interface. Point it at any directory of scripts and it builds a parent rex command on top of them β€” topics, subtopics, and standalone commands, all derived from the directory layout.

I built Rex because I kept forgetting what I’d named a given automation script and ended up digging through folders to find it. With Rex, finding and running the right one is a tab-complete away.

Setup

Point Rex at a directory of scripts:

rex dirs add ~/scripts

Rex automatically discovers topics and commands from any directories you’ve added. Multiple directories are supported and merged into the same namespace.

How Rex works

Rex uses directory layout to build a topic/subtopic command structure.

~/scripts/
β”œβ”€β”€ nas/                        # Topic: nas
β”‚   β”œβ”€β”€ nas-mount.sh            # β†’ rex nas mount
β”‚   β”œβ”€β”€ nas-sync.sh             # β†’ rex nas sync
β”‚   └── backup/                 # Subtopic: backup (requires max_depth >= 2)
β”‚       β”œβ”€β”€ backup-create.sh    # β†’ rex nas backup create
β”‚       └── backup-restore.sh   # β†’ rex nas backup restore
β”œβ”€β”€ network/                    # Topic: network
β”‚   β”œβ”€β”€ network-stats.sh        # β†’ rex network stats
β”‚   └── network-speed.sh        # β†’ rex network speed
└── stock-stats.sh              # β†’ rex stock-stats (standalone)
  • Topics / subtopics β€” nested subdirectories become command groups, up to max_depth.
  • Commands β€” executable scripts inside a topic dir become subcommands. The leaf topic prefix is auto-stripped if you’ve added it to the filename (e.g. nas-mount.sh β†’ mount).
  • Standalone β€” executables in the root of a configured directory become top-level commands.

Usage

rex                                        # Show help
rex list                                   # List all commands
rex <topic> <command> [args...]            # Run a topic command
rex <topic> <subtopic> <command> [args...] # Run a subtopic command (if max_depth allows)
rex <command> [args...]                    # Run a standalone command
rex new <command>                          # Create a standalone script
rex new <topic> [subtopic...] <command>    # Create a topic/subtopic script
rex edit <command>                         # Open a script in $EDITOR
rex edit <topic> [subtopic...] <command>   # Open a topic/subtopic script in $EDITOR

Managing directories

rex dirs                  # List configured directories
rex dirs add <path>       # Add a scripts directory
rex dirs remove <path>    # Remove a scripts directory

Documentation

  • Config β€” config file, max_depth, multi-directory edge cases
  • Script integration β€” descriptions, Raycast compat, rex.ignore, shell completions

License

MIT β€” see LICENSE.