diff --git a/CLAUDE.md b/CLAUDE.md index 32b844e..c8506a4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -21,9 +21,15 @@ vim/vimrc vim config (pathogen, molokai, syntastic, NERDTree) vim/autoload/ pathogen loader (committed) vim/colors/ molokai colorscheme (committed) bash/bashrc-{linux,osx} OS-detected bashrc +bin/{dt,dtach-router,claude-provider} CLI scripts deployed to ~/.local/bin .claude/{tasks,memory,audits}/ Claude working state ``` +`pymupdf`/`markdown_py` are NOT tracked — they are pipx entry-point shims, +recreated by `pipx install PyMuPDF Markdown` in install.sh. +`claude-provider` reads `$OPENROUTER_API_KEY` from the env — never hardcode it (the +original had a live key; it was scrubbed — see decisions/blockers). + ## Commands | Task | Command | diff --git a/README.md b/README.md index 3e3f14c..71d9d16 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,29 @@ Personal dotfiles — vim + bash configuration and a one-shot installer. +## Quick start + +Install everything (clone + setup) with one command: + +```sh +curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-install.sh | bash +``` + +(Runs a remote script through `bash` — see the [Install](#install) section for what it does and the manual alternative.) + ## What's inside | Path | Purpose | | -------------------- | -------------------------------------------------------------- | -| `install.sh` | Backs up existing config, then deploys vim + bashrc for a target. | +| `install.sh` | Installs apt packages + Docker, backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts. | | `vim/vimrc` | Vim config: pathogen, molokai, syntastic (C with `-Wall -Werror -Wextra`), NERDTree, 42-style canonical class generators (`:ClassH`, `:ClassC`). | | `vim/autoload/` | `pathogen.vim` plugin loader (committed). | | `vim/colors/` | `molokai.vim` colorscheme (committed). | | `bash/bashrc-linux` | bashrc for desktop Linux (git-aware prompt + command timer). | | `bash/bashrc-osx` | bashrc for macOS. | +| `bin/dt` | dtach session manager for claude-in-dtach sessions. | +| `bin/dtach-router` | SSH-login dashboard to resume dtach sessions (sourced from bashrc). | +| `bin/claude-provider`| Switch Claude Code between Anthropic and OpenRouter. | ## Install @@ -36,15 +49,40 @@ No argument — the OS is auto-detected. What it does: -1. On Debian/Ubuntu, installs `vim git gcc make pkg-config unzip dkms git-lfs` via `apt-get`. Skipped automatically where `apt-get` is absent (macOS). -2. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`. -3. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`. -4. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`. -5. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Copies it to `~/.bashrc`. +1. On Debian/Ubuntu, installs a set of CLI/dev packages via `apt-get` (see below). Skipped automatically where `apt-get` is absent (macOS). +2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin — skipped if `docker` is already present. +3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`. +4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`. +5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`. +6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Copies it to `~/.bashrc`. +7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. +8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`) into `~/.local/bin`. -The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup) and re-clones plugins. +### Packages installed (apt) -> macOS note: the `osx` target skips `apt-get` but still expects `vim`, `git`, and a Homebrew-installed toolchain to be present. +- **Build / VCS / C dev**: `vim git git-lfs git-filter-repo gcc make pkg-config dkms valgrind shellcheck` +- **Net / security / transport**: `curl gnupg ca-certificates apt-transport-https net-tools openssh-server cifs-utils lftp ftp` +- **Shell tooling**: `unzip tree tmux fzf dtach` +- **Runtimes**: `nodejs python3-pip pipx php-cli` +- **Media / doc CLI**: `ffmpeg wkhtmltopdf poppler-utils qpdf webp libavif-bin` +- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin` (via Docker's repo) +- **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`) + +The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup), re-clones plugins, skips Docker if already installed, and re-deploys the `bin/` scripts. + +> Notes: the package list is Debian/Ubuntu-specific, and the Docker repo step assumes **Ubuntu**. On macOS the whole `apt-get` block is skipped — install `vim`/`git`/toolchain via Homebrew yourself. + +### CLI scripts (`bin/`) + +Deployed to `~/.local/bin` (must be on `PATH` — `pipx ensurepath` adds it): + +- **`dt`** — manage claude-in-dtach sessions (`dt ls|at|kill`). Needs `dtach` + `fzf`. +- **`dtach-router`** — source from `~/.bashrc` to get a session dashboard on SSH login. Needs `dt`, `dtach`, `fzf`. +- **`claude-provider`** — switch Claude Code between Anthropic and OpenRouter. + OpenRouter mode reads the key from **`$OPENROUTER_API_KEY`** (never hardcoded). Export it from a private, untracked file, e.g. `~/.bashrc.local`: + ```sh + export OPENROUTER_API_KEY="" + ``` ## Requirements diff --git a/install.sh b/install.sh index a29b100..7f69df7 100755 --- a/install.sh +++ b/install.sh @@ -6,11 +6,43 @@ set -euo pipefail # Resolve the repo root so the script works from any working directory. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# Set up Docker's official Ubuntu apt repo, then install the engine + compose plugin. +# Idempotent: skips entirely if docker is already on PATH. Ubuntu-only (uses the ubuntu repo). +install_docker() { + if command -v docker >/dev/null 2>&1; then + echo "docker already installed — skipping Docker repo setup" + return + fi + echo "Setting up Docker apt repo" + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + local codename arch + # shellcheck disable=SC1091 # /etc/os-release is sourced at runtime, not available to the linter. + codename="$(. /etc/os-release && echo "${VERSION_CODENAME}")" + arch="$(dpkg --print-architecture)" + echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${codename} stable" | + sudo tee /etc/apt/sources.list.d/docker.list >/dev/null + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +} + # System packages: Debian/Ubuntu only. Skipped where apt-get is absent (e.g. macOS). if command -v apt-get >/dev/null 2>&1; then sudo apt-get update sudo apt-get upgrade -y - sudo apt-get install -y vim git gcc make pkg-config unzip dkms git-lfs + + # Build + version control + C dev tooling. + sudo apt-get install -y \ + vim git git-lfs git-filter-repo gcc make pkg-config dkms valgrind shellcheck \ + curl gnupg ca-certificates apt-transport-https \ + unzip tree tmux fzf dtach net-tools \ + openssh-server cifs-utils lftp ftp \ + nodejs python3-pip pipx php-cli \ + ffmpeg wkhtmltopdf poppler-utils qpdf webp libavif-bin + + # Docker (separate repo). + install_docker else echo "apt-get not found — skipping system packages (install vim/git manually)." fi @@ -51,5 +83,20 @@ fi echo "Deploying $bashrc" cp "$SCRIPT_DIR/$bashrc" "$HOME/.bashrc" +# Python CLIs via pipx (run as the user, never sudo). Skipped if pipx is absent. +if command -v pipx >/dev/null 2>&1; then + echo "Installing pipx CLIs (PyMuPDF -> pymupdf, Markdown -> markdown_py)" + pipx install PyMuPDF || pipx upgrade PyMuPDF + pipx install Markdown || pipx upgrade Markdown + pipx ensurepath >/dev/null +fi + +# Deploy personal CLI scripts to ~/.local/bin (dt, dtach-router, claude-provider). +echo "Deploying CLI scripts to ~/.local/bin" +mkdir -p "$HOME/.local/bin" +cp "$SCRIPT_DIR"/bin/* "$HOME/.local/bin/" +chmod +x "$HOME"/.local/bin/dt "$HOME"/.local/bin/dtach-router "$HOME"/.local/bin/claude-provider + echo "Done. Restart your shell or run: source ~/.bashrc" echo "If you use zsh, switch to bash to enjoy these settings =)" +echo "Note: ~/.local/bin must be on PATH (pipx ensurepath handles it; re-login if needed)."