From b7b643ddf9ac5b79f6f9ae08413b7d357ee1ddbd Mon Sep 17 00:00:00 2001
From: Marty Oehme <marty.oehme@gmail.com>
Date: Sat, 22 Feb 2025 18:12:57 +0100
Subject: [PATCH] jj: Add aliases to jump to most recent changes

`jed` allows editing the 'latest' (i.e. most recent, timewise) change we
can reach following the descendants of the current working copy.

In essence, this allows us to quickly jump to the head of whatever
branch we are on.

Similarly, `jet` goes to the newest descendant of the 'trunk' branch
(i.e. generally 'master' or 'main').
And `jel` just goes to the newest commit in general out of all commits
in the repo.

These have a lot of overlap and I might end up removing the latter two
if I am not using them much, which may be the case.
---
 vcs/jj/config/sh/alias.d/jj.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/vcs/jj/config/sh/alias.d/jj.sh b/vcs/jj/config/sh/alias.d/jj.sh
index 8e1c841..c40349e 100644
--- a/vcs/jj/config/sh/alias.d/jj.sh
+++ b/vcs/jj/config/sh/alias.d/jj.sh
@@ -25,6 +25,13 @@ alias jen="jj next --edit"
 alias jep="jj prev --edit"
 alias jenn="jj next"
 alias jepp="jj prev"
+# edit the 'newest' head descendant of current working copy
+# usually means 'get me to head of current branch'
+alias jed="jj edit -r 'latest(heads(descendants(@)))'"
+# go to the newest head of the trunk branch
+alias jet="jj edit -r 'latest(heads(descendants(trunk())))'"
+# simply go to the newest commit, i.e. our last change committed
+alias jel="jj edit -r 'latest(all())'"
 
 # for squash-and-go workflows
 # https://steveklabnik.github.io/jujutsu-tutorial/real-world-workflows/the-squash-workflow.html