Created
October 20, 2026 07:04
-
-
Save arialdomartini/655d59e7763d1e54edfad1b0e8153f6f to your computer and use it in GitHub Desktop.
jj-watch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Refresh jj log whenever the latest Jujutsu operation changes. | |
| # | |
| # JJ_LOG_WATCH_INTERVAL to change the polling interval (default: 0.5 seconds). | |
| set -u | |
| interval="${JJ_LOG_WATCH_INTERVAL:-0.5}" | |
| latest_operation() { | |
| # Keep the watcher from snapshotting the working copy and | |
| # accidentally creating an operation of its own. | |
| jj --at-op=@ --ignore-working-copy operation log --limit 1 --no-graph --template 'id' | |
| } | |
| render_log() { | |
| # Clear the terminal and position the cursor at its top-left corner. | |
| clear && jj st && echo && jj log | |
| } | |
| previous_operation="$(latest_operation)" || { | |
| echo "Unable to read the latest Jujutsu operation." >&2 | |
| exit 1 | |
| } | |
| render_log | |
| while sleep "$interval"; do | |
| current_operation="$(latest_operation)" || continue | |
| if [[ "$current_operation" != "$previous_operation" ]]; then | |
| previous_operation="$current_operation" | |
| render_log | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment