---
name: ecc-terminal-ops
description: Efficient terminal operations including command history, pipeline patterns, job control, and workflow automation techniques.
---

# Terminal Ops

Efficient terminal operations and workflow automation.

## Core Patterns

### Find and Act
```bash
# Find files and do something
find . -name "*.py" -exec grep -l "TODO" {} \;

# Git grep
git grep "deprecated_function" -- '*.ts'

# Recent files
find . -name "*.md" -mtime -7
```

### Pipeline Patterns
```bash
# Chain with error handling
cmd1 && cmd2 || echo "Failed at cmd1"

# Pipe with tee (log and show)
cmd | tee output.log

# Parallel execution
cmd1 & cmd2 & wait
```

### History
```bash
# Search history
Ctrl+R

# Repeat last command
!!

# Use last argument
!$
```

## Workflow Automation

### Watch and Reload
```bash
# Auto-restart on file changes
find . -name "*.py" | entr -r python app.py

# Watch directory for changes
inotifywait -m -r src/ -e modify |
    while read path action file; do
        echo "$file changed"
    done
```

### Quick Edits
```bash
# Edit most recent file matching pattern
vim $(ls -t *.py | head -1)

# Open files with git changes
vim $(git diff --name-only)

# Edit files with errors (after build)
vim $(grep -rl "ERROR" logs/)
```

## SSH and Remote

```bash
# Jump host
ssh -J bastion.example.com target.internal

# Tunnel
ssh -L 8080:localhost:8080 remote

# Quick file transfer
tar czf - project/ | ssh remote "tar xzf -"
```
