Skip to main content

shcripts

shcripts logo

A powerful CLI tool for managing bash scripts and SLURM job submissions with template support and job tracking.

Features

  • 📝 Script Template Management: Store and organize reusable bash script templates
  • 🔄 Jinja2 Templating: Use variables in templates for flexible script generation
  • 🚀 SLURM Job Submission: Submit jobs directly from templates or script files
  • 📊 Job Tracking: Keep track of submitted jobs with automatic status updates
  • 🎨 Rich CLI Interface: Beautiful terminal output with syntax highlighting
  • 📦 Organized Storage: Category and tag-based organization of scripts

Installation

# Clone the repository
git clone <repository-url>
cd shcripts

# Install with uv
uv sync

# Or install in development mode
uv pip install -e .

Quick Start

1. Add a Script Template

# Add the example SLURM script as a template
shcripts add montepython src/shcripts/template/example.sh \
  --description "MontePython MCMC run with BOSS/eBOSS data" \
  --category "mcmc" \
  --tag slurm --tag python

2. List Available Templates

# List all templates
shcripts list

# Filter by category
shcripts list --category mcmc

# Filter by tag
shcripts list --tag slurm

3. View a Template

# Show template with syntax highlighting
shcripts show montepython

# Show raw content
shcripts show montepython --raw

4. Generate Scripts from Templates

Templates support Jinja2 variables. Modify your template to include variables:

#!/bin/bash
#SBATCH --job-name={{ job_name }}
#SBATCH --time={{ time }}
#SBATCH --ntasks={{ ntasks }}
#SBATCH --mem={{ memory }}

echo "Running {{ description }}"
# Your commands here

Generate with variables:

# Generate and print to stdout
shcripts generate montepython \
  --var job_name=my-job \
  --var time=10:00:00 \
  --var ntasks=16 \
  --var memory=64GB \
  --var description="My analysis run"

# Generate to file
shcripts generate montepython \
  --output my_job.sh \
  --var job_name=my-job \
  --var time=10:00:00

5. Submit SLURM Jobs

# Submit from a template
shcripts submit --template montepython \
  --var job_name=run-001 \
  --var time=48:00:00

# Dry run to preview
shcripts submit --template montepython \
  --var job_name=test \
  --dry-run

# Submit from a script file
shcripts submit path/to/script.sh

6. Track Job Status

# Check specific job
shcripts status 12345

# List all tracked jobs
shcripts status --all

# View submission history
shcripts history

# Limit history results
shcripts history --limit 5

7. Remove Templates

# Remove with confirmation
shcripts remove montepython

# Force remove without confirmation
shcripts remove montepython --force

Commands Reference

add

Add a new script template to the collection.

shcripts add <name> <script-path> [OPTIONS]

Options:
  -d, --description TEXT   Script description
  -c, --category TEXT      Script category [default: general]
  -t, --tag TEXT           Tags (can be used multiple times)

list

List all stored script templates.

shcripts list [OPTIONS]

Options:
  -c, --category TEXT   Filter by category
  -t, --tag TEXT        Filter by tag

show

Display the content of a script template.

shcripts show <name> [OPTIONS]

Options:
  -r, --raw   Show raw file content without syntax highlighting

generate

Generate a script from a template with variable substitution.

shcripts generate <template-name> [OPTIONS]

Options:
  -o, --output TEXT   Output file path
  -v, --var TEXT      Variables in key=value format (can be used multiple times)

submit

Submit a SLURM job from a file or template.

shcripts submit [script-path] [OPTIONS]

Options:
  -t, --template TEXT   Template name to use
  -v, --var TEXT        Variables in key=value format (can be used multiple times)
  --dry-run             Show what would be submitted without submitting

status

Check the status of SLURM jobs.

shcripts status [job-id] [OPTIONS]

Options:
  -a, --all   Show all tracked jobs

history

Show job submission history.

shcripts history [OPTIONS]

Options:
  -n, --limit INTEGER   Number of recent jobs to show [default: 10]

remove

Remove a script template from the collection.

shcripts remove <name> [OPTIONS]

Options:
  -f, --force   Skip confirmation

Template Variables

Templates use Jinja2 syntax for variables. Common patterns:

# Simple variable substitution
{{ variable_name }}

# Default values
{{ variable_name | default("default_value") }}

# Conditionals
{% if condition %}
  # commands
{% endif %}

# Loops
{% for item in list %}
  echo {{ item }}
{% endfor %}

Storage

All data is stored in ~/.shcripts/:

  • templates/ - Script template files
  • scripts.json - Template metadata
  • jobs.json - Job submission history

Example Workflow

  1. Create a template with variables:

    # Edit template/analysis.sh with Jinja2 variables
    # Add it to shcripts
    shcripts add analysis template/analysis.sh \
      --description "General analysis pipeline" \
      --category "data-analysis"
    
  2. Submit multiple jobs with different parameters:

    for dataset in data1 data2 data3; do
      shcripts submit --template analysis \
        --var dataset=$dataset \
        --var output_dir=/results/$dataset
    done
    
  3. Monitor all jobs:

    shcripts status --all
    
  4. Review history:

    shcripts history --limit 20
    

Tips

  • Use descriptive template names and categories for easy organization
  • Add multiple tags to templates for flexible filtering
  • Use --dry-run to preview generated scripts before submission
  • Keep template variables documented in the script description
  • Use the show command to review templates before generating scripts

Requirements

  • Python >= 3.9
  • SLURM (for job submission features)
  • Dependencies: typer, rich, jinja2 (managed by uv)

License

MIT License

Copyright (c) 2025, Rodrigo Calderon

Metadata

Release files for shcripts 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shcripts 0.0.1
File Size Uploaded Provenance Actions
shcripts-0.0.1.tar.gz 10.3 kB Without provenance Details for shcripts-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shcripts 0.0.1
File Interpreter ABI Platform Actions
shcripts-0.0.1-py3-none-any.whl Python 3 none any Details for shcripts-0.0.1-py3-none-any.whl

Total release size: 23.2 kB

Release files / shcripts-0.0.1.tar.gz

Download URL shcripts-0.0.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
629ab20f68dc38e41def768c16d0e83a61ed39e0d9cc37118d88de91aff45362
BLAKE2b-256 checksum
How to use checksums
eb29be3bdfe6f6a7d28830c0c6bd2a85b88b8c94e6848813def27e9fdeb3f6b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / shcripts-0.0.1-py3-none-any.whl

Download URL shcripts-0.0.1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18f488f7acaf95939e4ba308b462edb2d13c990e8c4e6e09860e12c2ff60459f
BLAKE2b-256 checksum
How to use checksums
a64622925ff37ed77827238c7fd488134e274f12702c7424fdc4cb97c92ae4a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for shcripts 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page