Skip to content

HotThoughts/jj.fish

Repository files navigation

jj.fish 🌿

Fish shell abbreviations for jj (Jujutsu) - fast shortcuts for common operations.

Installation

fisher install HotThoughts/jj.fish

Requirements: Fish 3.4+, jj 0.29+

Abbreviations

Core Operations

Abbr Command Abbr Command
jjl jj log jjst jj st
jjll jj log --limit jjlr jj log --revisions
jjd jj describe jjdm jj describe -m
jjn jj new jjnm jj new main
jjnmo jj new main@origin jja jj abandon
jjr jj rebase jjrmo jj rebase -d main@origin
jjc jj commit jjci jj commit -i

Viewing and Comparing

Abbr Command Abbr Command
jjs jj show jjdf jj diff
jjid jj interdiff jjev jj evolog

Editing Changes

Abbr Command Abbr Command
jje jj edit jjsq jj squash
jjsqi jj squash -i jjsp jj split
jjde jj diffedit jjab jj absorb

Navigation

Abbr Command Abbr Command
jjnx jj next jjpv jj prev

Bookmarks (Branches)

Abbr Command Abbr Command
jjb jj bookmark jjbl jj bookmark list
jjbs jj bookmark set jjbt jj bookmark track
jjbd jj bookmark delete

Operations

Abbr Command Abbr Command
jjop jj op jjopl jj op log
jju jj undo

Conflict Resolution

Abbr Command Abbr Command
jjrs jj resolve jjrt jj restore

Advanced Operations

Abbr Command Abbr Command
jjdu jj duplicate jjrv jj revert
jjpa jj parallelize

Short Alternatives

Abbr Command Abbr Command
ji jj git init --colocate . jp jj git push
jf jj git fetch jnm jj new main@origin
jd jj describe -m jr jj rebase -d main@origin
jc jj commit jci jj commit -i
jbt jj bookmark track jbs jj bookmark set

AI-Powered Commit Messages

Function Description
jjad AI-generated description via jj describe
jjac AI-generated commit via jj commit

Uses AI to analyze your changes and generate conventional commit messages.

Supported AI tools (auto-detected):

  • GitHub Copilot standalone (copilot)
  • Cursor Agent (cursor-agent)
  • Claude CLI (claude)

Usage:

# If only one AI tool is installed, it's used automatically
jjad

# If multiple tools are available, you'll get an interactive selection:
# Multiple AI tools detected. Select one:
#   1) copilot
#   2) cursor-agent
#   3) claude
# Choice [1-3]:

# Or set a preferred tool via environment variable
set -Ux JJ_AI_TOOL copilot  # Options: copilot, cursor-agent, claude

PR Creation

Function Description
jjpr [change-id] Push change and create GitHub PR (defaults to @)

Quick Start

# Initialize repo and start working
ji
jjst

# Create new change, make edits, describe
jjnm
jjdm "feat: add feature"

# View history and diff
jjl
jjdf

# Push current change and create PR
jjpr

How It Works

Type abbreviation + space → expands to full command:

  • jjl + space → jj log
  • jjst + space → jj st

Customization

# Add your own
abbr --add jjs 'jj show'

# Remove unwanted ones
abbr --erase jjnm

Troubleshooting

"jj not found" error

The plugin requires jj to be installed and in your PATH.

Install jj:

# macOS
brew install jj

# Or from source
cargo install --git https://github.com/martinvonz/jj jj-cli

Verify installation:

jj --version

"gh CLI not found" when using jjpr

The jjpr function requires the GitHub CLI to create pull requests.

Install gh:

# macOS
brew install gh

# Linux
sudo apt install gh

Authenticate:

gh auth login

Abbreviations not working

  1. Check plugin is loaded:

    abbr --show | grep jj

    Should show jj abbreviations.

  2. Reload Fish config:

    source ~/.config/fish/config.fish
  3. Reinstall plugin:

    fisher remove HotThoughts/jj.fish
    fisher install HotThoughts/jj.fish

jjpr fails with "could not determine branch name"

This occurs when jj doesn't output the expected branch name format after pushing.

Workaround:

  1. Push manually: jj git push -c <change-id>
  2. Note the branch name from output
  3. Create PR manually: gh pr create --head <branch-name>

Report: If this happens consistently, please file an issue with your jj version (jj --version).

Using repositories with non-"main" default branches

The jjpr function automatically detects your repository's default branch (main, master, develop, etc.) and creates PRs against it. No configuration needed.

Change ID not found

Ensure you're using a valid change ID from jj log:

jjl              # View change history
jjpr abc123def   # Use the change ID prefix (first 7-12 chars)

Development

Pre-commit Hooks

This project uses pre-commit to run automated checks before pushing to ensure code quality.

Setup (one-time):

# Install pre-commit (if not already installed)
brew install pre-commit  # macOS
# or: pip install pre-commit

# Install the git pre-push hook
pre-commit install --hook-type pre-push

What gets checked:

  • Fish shell syntax validation (fish --no-execute)
  • Fish shell indentation (fish_indent --check)
  • Trailing whitespace and end-of-file fixes
  • YAML validity
  • Test suite execution

Manual runs:

# Run all hooks on all files
pre-commit run --hook-stage pre-push --all-files

# Run specific hook
pre-commit run --hook-stage pre-push fish-syntax-check

# Auto-fix formatting issues
pre-commit run --hook-stage pre-push --all-files

Integration with jj:

Since jj doesn't natively trigger git hooks (see jj issue #405), you can configure a jj alias to run pre-commit checks on jj-tracked changed files.

Setup (one-time):

Add this alias to .jj/repo/config.toml:

[aliases]
pre-commit = [
  "util",
  "exec",
  "--",
  "fish",
  "-c",
  "jj diff -r @ --name-only --no-pager | xargs pre-commit run --files",
]

This alias runs pre-commit checks only on files changed in your current change (using jj diff -r @ --name-only), making it fast and efficient.

Usage:

jj pre-commit     # Runs pre-commit checks on changed files in current change

Manual runs (all files):

pre-commit run --hook-stage pre-push --all-files

Manual runs (changed files only, using jj):

# Get changed files from jj and run pre-commit on them
jj diff -r @ --name-only --no-pager | xargs pre-commit run --files

License

MIT

About

A Fish shell plugin for jj (Jujutsu) with GitHub PR automation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages