-
-
Notifications
You must be signed in to change notification settings - Fork 0
User Guide
Joao Palma edited this page Jan 29, 2026
·
4 revisions
← Installation Guide | Home | Script Development →
- Quick Start Tutorial
- Core Commands
- Script Management
- Documentation Features
- Working with Categories
- Best Practices
- Advanced Usage
- Next Steps
Let's create and use your first DotRun script:
# Create a new script called 'hello'
dr set hello
# This opens your editor with a template. Add this content:
#!/usr/bin/env bash
### DOC
# Hello World Script
#
# A simple demonstration script for DotRun
#
# Usage: dr hello [name]
#
# Arguments:
# name - Optional name to greet (default: World)
#
# Examples:
# dr hello # Outputs: Hello, World!
# dr hello Alice # Outputs: Hello, Alice!
### DOC
name="${1:-World}"
echo "Hello, $name!"# Run with default
dr hello
# Output: Hello, World!
# Run with argument
dr hello DotRun
# Output: Hello, DotRun!# View the inline documentation
dr help hello
# If you have glow installed, it renders as formatted markdowndr <script> # Run a script
dr <script> [args] # Run with arguments
dr <category>/<script> # Run categorized scriptdr set <name> # Create new script or edit existing
dr rm <name> # Remove script
dr mv <old> <new> # Move/rename script
dr cp <source> <dest> # Copy scriptdr -l, --list # List all scripts
dr -L, --list-verbose # List with descriptions
dr help <script> # Show script documentation
dr --version # Show version
dr --info # Show installation infoWhen you create a script with dr set, you get:
- Executable permissions set automatically
- Documentation template included
- ShellCheck linting (if installed)
- Git tracking (automatic commit)
# Create in a category
dr set git/cleanup
# Create with custom template
dr set deploy/prod --template=deployCategories help organize related scripts:
# Create categorized scripts
dr set git/branch-cleanup
dr set docker/cleanup
dr set deploy/staging
# List scripts by category
dr -l git/ # List only git scripts
dr -L docker/ # Verbose list of docker scripts# Move to a category
dr mv cleanup git/cleanup
# Rename within category
dr mv git/cleanup git/branch-cleanup
# Copy for modification
dr cp deploy/staging deploy/productionEvery script should include a ### DOC section:
#!/usr/bin/env bash
### DOC
# Script Name
#
# Brief description of what this script does
#
# Usage: dr scriptname [options]
#
# Options:
# -h, --help Show this help message
# -v, --verbose Enable verbose output
#
# Examples:
# dr scriptname
# dr scriptname --verbose
#
# Dependencies:
# - tool1: Description
# - tool2: Description
### DOC
# Script implementation hereCreate comprehensive guides in docs/:
# Create documentation
dr doc create git-workflows
# View documentation
dr doc view git-workflows
# List all documentation
dr doc listOrganize scripts by purpose:
-
git/- Git workflows and utilities -
docker/- Container management -
deploy/- Deployment scripts -
test/- Testing utilities -
setup/- Environment setup -
utils/- General utilities
- Consistent Naming: Use lowercase, hyphen-separated names
- Clear Purpose: Each category should have a clear theme
- Documentation: Include a README in each category
-
Shared Functions: Use
_lib.shfor shared code
Example structure:
~/.config/dotrun/bin/
├── git/
│ ├── _lib.sh # Shared git functions
│ ├── branch-cleanup
│ ├── quick-commit
│ └── README.md
├── deploy/
│ ├── staging
│ ├── production
│ └── rollback
└── utils/
├── backup
└── clean-logs
- Always include
### DOCsections - Document parameters and examples
- Keep documentation up-to-date
set -euo pipefail # Exit on error, undefined vars, pipe failures- Use ShellCheck for linting
- Follow naming conventions
- Include progress messages
# Commit changes regularly
cd ~/.config/dotrun
git add -A
git commit -m "Add deployment scripts"Access arguments in your scripts:
#!/usr/bin/env bash
# All arguments
echo "All args: $@"
# Individual arguments
first_arg="$1"
second_arg="${2:-default}"
# Number of arguments
if [ $# -eq 0 ]; then
echo "No arguments provided"
fiDotRun provides these variables to scripts:
DR_HOME # DotRun workspace directory
DR_BIN # Scripts directory
DR_DOCS # Documentation directory
DR_SCRIPT # Current script name
DR_CATEGORY # Current script category (if any)Create reusable functions:
# In git/_lib.sh
git_current_branch() {
git rev-parse --abbrev-ref HEAD
}
# In git/push-upstream
source "$(dirname "$0")/_lib.sh"
branch=$(git_current_branch)
git push -u origin "$branch"Share script sets with your team:
# Export a collection
dr collection export git-tools ~/git-tools.tar.gz
# Import a collection
dr collection import ~/git-tools.tar.gz
# List collections
dr collection listNow that you understand the basics:
- Develop Scripts: Learn Script Development best practices
- Team Collaboration: Set up Team Workflows
- Configure Environment: Explore Configuration Management
- Manage Aliases: Use the Alias System
- Browse Examples: Check Example Scripts