#!/usr/bin/env zsh# ── jj.zsh : jujutsu (jj) VCS ────────────────────────────────────────────────# User config lives in ~/.config/jj/config.toml (`jj config edit --user`).# Completions ship with the brew formula in /opt/homebrew/share/zsh/site-functions.command -v jj >/dev/null 2>&1||return# ── core verbs ───────────────────────────────────────────────────────────────aliasj='jj'aliasjs='jj status'aliasjl='jj log'aliasjll='jj log -T builtin_log_detailed'aliasjd='jj diff'aliasjsh='jj show'aliasjn='jj new'# start a fresh change on top of @aliasje='jj edit'# move the working copy onto an existing changealiasjdm='jj describe -m'# set the description of @aliasjsq='jj squash'# fold @ into its parentaliasjsp='jj split'aliasjr='jj rebase'aliasjab='jj abandon'# ── bookmarks (jj's branches) ────────────────────────────────────────────────aliasjb='jj bookmark list'aliasjbc='jj bookmark create'aliasjbm='jj bookmark move'aliasjtug='jj tug'# drag nearest bookmark up to @-# ── git remotes ──────────────────────────────────────────────────────────────aliasjf='jj git fetch --all-remotes'aliasjpush='jj git push'aliasjpushc='jj git push --change @'# auto-name a bookmark for this change# Commit with an ISO date + hostname in the description. With --push, the# completed change is @- because `jj commit` creates a fresh working-copy child.aliasjcm='jj-commit'aliasjcmp='jj-commit --push'# Let the message write itself: jj-msg (~/.local/bin) reads the diff of @, gets# a conventional-commit subject + bullets from `claude -p`, strips any# attribution so the commit is signed as you, and commits through jj-commit so# the Commit-Date/Commit-Host trailers come from one place. -t "subject" keeps# your own first line; --no-ai (or VCS_MSG_AI=0) summarises the file list# instead. The message is the only thing on stdout: jj commit -m "$(jm)"aliasjm='jj-msg'# just print italiasjmd='jj-msg describe'# describe @ with italiasjme='jj-msg edit'# describe, then polish it in $EDITORaliasjmc='jj-msg commit'# seal @ with italiasjmcp='jj-msg commit --push'# ── operation log : jj's undo history for the whole repo ─────────────────────aliasjop='jj op log'aliasjundo='jj undo'aliasjrestore='jj op restore'# jump the whole repo back to an operation id# ── repo bootstrap ───────────────────────────────────────────────────────────# Colocated = .jj and .git side by side, so git commands keep working.jjinit(){ jj git init --colocate "${1:-.}"; }jjclone(){ jj git clone --colocate "$@"; }# ── cheatsheet ───────────────────────────────────────────────────────────────jjhelp(){ print -P "%F{#c4a7e7} jj quick reference%f" print -P "%F{#908caa} no staging area — the working copy IS a commit (@)%f" cat <<'HELP' jj st / js what changed in @ jj new / jn begin a new change on top jj describe -m "x" (re)write @'s message — no --amend needed jj-commit "x" / jcm commit with Commit-Date + Commit-Host trailers jcmp "x" commit, then push the completed change (@-) jm / jmd / jme / jmc the message, written from the diff: print / describe / edit / commit jj squash / jsq fold @ into its parent jj edit <rev> / je make any change the working copy jj bookmark move ... bookmarks replace branches; nothing is checked out jj git push --change @ push @ under an auto-named bookmark jj op log / jop every repo mutation, undoable jj undo / jundo revert the last operation (yes, even a rebase) revsets: @ = working copy, @- = parent, mine, wip, stack, trunk()HELP}