Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Shell Integration

Integrate zo into your shell for seamless AI assistance in your terminal workflow.

Quick Functions

Add these to ~/.bashrc or ~/.zshrc:

Explain Command

explain() {
    echo "$*" | zo 'Explain this command and what it does'
}

Usage:

explain tar -xzf archive.tar.gz
explain find . -name '*.log' -mtime +7 -delete
explain awk '{print $1}' file.txt | sort | uniq -c

How-To Helper

howto() {
    zo 'How do I $* in bash/zsh? Give me the exact command'
}

Usage:

howto find all python files modified today
howto compress a directory excluding node_modules
howto count lines of code in all js files

Error Fixer

fix() {
    "$@" 2>&1 | zo 'Why did this command fail and how do I fix it?'
}

Usage:

fix cargo build
fix npm install
fix git push

Advanced Functions

Git Helper

# Generate commit message
gcm() {
    local msg=$(git diff --cached | zo 'Generate concise conventional commit message')
    echo "Commit message: $msg"
    echo "Use this message? [Y/n]"
    read -r response
    if [[ ! "$response" =~ ^[Nn]$ ]]; then
        git commit -m "$msg"
    fi
}
 
# Review before commit
grc() {
    git diff --cached | zo /reviewer 'Quick review of staged changes'
}
 
# PR description
prdesc() {
    local branch=${1:-main}
    git diff "$branch"...HEAD | zo 'Generate PR description' > pr.md
    cat pr.md
}

Log Analysis

# Analyze recent logs
logs() {
    local lines=${1:-100}
    tail -n "$lines" /var/log/syslog | zo 'Summarize errors and issues'
}
 
# Find patterns
logpattern() {
    tail -n 1000 "$1" | zo 'Find patterns and anomalies in these logs'
}

System Diagnostics

# Memory check
memcheck() {
    ps aux --sort=-%mem | head -20 | zo 'Which processes should I investigate?'
}
 
# Disk usage
diskcheck() {
    du -sh * | sort -hr | head -20 | zo 'What is using my disk space?'
}
 
# Network check
netcheck() {
    netstat -tuln | zo 'Any suspicious network connections?'
}

Aliases

Basic Aliases

# ~/.bashrc or ~/.zshrc
 
alias chat='zo --chat'
alias review='zo /reviewer'
alias code='zo /coder'
alias debug='zo /debugger'
alias explain-code='zo /teacher'

Usage:

chat 'Let us discuss system design'
chat-code @main.rs 'Refactor this'
chat-review @pr.diff 'Review this PR'

Interactive Prompts

Multi-line Input

multiask() {
    echo "Enter your question (Ctrl+D when done):"
    local input=$(cat)
    zo "$input"
}

Usage:

multiask
# Type multiple lines
# Press Ctrl+D

File Selection

reviewfile() {
    local file=$(find . -name '*.rs' | fzf)
    if [ -n "$file" ]; then
        zo /reviewer @"$file" 'Review this code'
    fi
}

Requires fzf installed.

Workflow Integration

Development Workflow

# ~/.bashrc
 
# Before committing
pre-commit-check() {
    git diff --cached | zo /reviewer 'Quick sanity check. Flag critical issues only.'
}
 
# After error
fix-last() {
    fc -ln -1 | zo 'This command failed. Why and how to fix?'
}
 
# Explain recent commands
history-explain() {
    history | tail -5 | zo 'Explain what these commands do'
}

Documentation Workflow

# README generator
readme() {
    zo /writer @*.js 'Generate comprehensive !README.md with:
- Overview
- Installation
- Usage examples
- API documentation
- Contributing guidelines'
}

Data Analysis Workflow

# Quick CSV stats
csvstats() {
    head -100 "$1" | zo 'Calculate basic statistics for each column'
}
 
# JSON query helper
jqhelp() {
    echo "$1" | zo 'Generate jq command to: $2'
}
 
# SQL generator
sqlgen() {
    zo @schema.sql 'Generate SQL query: $*'
}

Advanced Pipelines

Multi-stage Analysis

# Code → Review → Fix → Test
pipeline-fix() {
    local file="$1"
    
    # Review
    local issues=$(zo /reviewer @"$file" 'List critical issues as JSON')
    
    # Fix
    echo "$issues" | zo /coder 'Fix these issues in the code'
    
    # Verify
    zo /reviewer @"$file" 'Verify fixes'
}

Data Processing Pipeline

# Fetch → Parse → Analyze → Visualize
api-analyze() {
    curl -s "$1" \
        | zo 'Extract key data as CSV' \
        | zo 'Generate summary statistics' \
        | zo 'Suggest visualization approach'
}

Shell Scripting

Error Handling Script

#!/bin/bash
 
run_with_ai_help() {
    local cmd="$*"
    local output
    local exit_code
    
    # Run command
    output=$($cmd 2>&1)
    exit_code=$?
    
    if [ $exit_code -ne 0 ]; then
        echo "Command failed:"
        echo "$output"
        echo ""
        echo "AI Analysis:"
        echo "$output" | zo /debugger 'Diagnose and suggest fix'
    else
        echo "$output"
    fi
    
    return $exit_code
}

Automated Code Review

#!/bin/bash
 
# review-pr.sh
branch="${1:-main}"
 
echo "🔍 Reviewing changes..."
 
# Get diff
diff=$(git diff "$branch"...HEAD)
 
# AI review
review=$(echo "$diff" | zo /reviewer 'Comprehensive PR review')
 
# Save and display
echo "$review" > review.md
cat review.md
 
echo "✅ Review complete"

Productivity Shortcuts

Quick Reference

# Man page summaries
mans() {
    man "$1" | zo 'Summarize the most useful options'
}
 
# Command cheatsheet
cheat() {
    zo 'Give me a cheatsheet for $1 with common usage examples'
}
 
# Language syntax
syntax() {
    zo 'Show me $1 syntax for: $2'
}

Usage:

mans grep
cheat docker
syntax python 'list comprehension'

Learning Helper

# Explain with examples
learn() {
    zo /teacher "$*"
}
 
# Code walkthrough
walkthrough() {
    zo @"$1" /teacher 'Explain this code step by step'
}
 
# Concept comparison
compare() {
    zo /teacher 'Compare and contrast: $1 vs $2'
}

Installation

Add to your shell configuration:

# ~/.bashrc or ~/.zshrc
 
# Source zo helper functions
if [ -f ~/.zo_functions.sh ]; then
    source ~/.zo_functions.sh
fi

Create ~/.zo_functions.sh with your favorite functions.

Next Steps