diff --git a/home/.config/templates/.pre-commit-config.yaml b/home/.config/templates/.pre-commit-config.yaml new file mode 100644 index 0000000..e6c565f --- /dev/null +++ b/home/.config/templates/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +# Sensible defaults — keeps ruff + ty fast on every commit. +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.0 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + - repo: https://github.com/astral-sh/ty-pre-commit + rev: 0.0.1a8 + hooks: + - id: ty-check + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-added-large-files + args: ['--maxkb=1024'] + - id: check-merge-conflict diff --git a/home/.zshrc b/home/.zshrc index e8e5aec..c4f2190 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -30,7 +30,34 @@ alias aider-fast='AIDER_MODEL=$MODEL_FAST aider' mkproj() { local name="$1" [ -z "$name" ] && echo 'usage: mkproj ' && return 1 - mkdir -p "$HOME/work/$name" && cd "$HOME/work/$name" && uv init + local dir="$HOME/work/$name" + mkdir -p "$dir" && cd "$dir" || return 1 + + uv init --no-readme >/dev/null + + # tag pyproject with workspace + owner from Coder env (when present) + if [ -n "${CODER_WORKSPACE_NAME:-}" ]; then + cat >> pyproject.toml </dev/null + + # Dev tooling + pre-commit + uv add --dev pytest ruff ty pre-commit >/dev/null 2>&1 || true + cp -n "$HOME/.config/templates/.pre-commit-config.yaml" . 2>/dev/null + uv run pre-commit install >/dev/null 2>&1 || true + + # First commit + git init -q -b main + git add . && git commit -q -m "chore: scaffold $name (mkproj)" || true + echo "$name ready at $dir" } # Docker — detach from a running attach with Ctrl+P, Ctrl+Q