emacs = "emacsclient --create-frame";
grep = "grep --color";
du = "du --apparent-size"; # ExplanationNote: shows the size __before__ ZFS' compression.
- j = "jj"; # jujutsu
- jnl-b = "sudo journalctl -b";
- jnl-f = "sudo journalctl -f -u";
- jnl-f200 = "sudo journalctl -f -n 200 -u";
- jnl-ftoday = "sudo journalctl -f --since today -u";
+ jb = "sudo journalctl -b";
+ jf = "sudo journalctl -f -u";
+ jf200 = "sudo journalctl -f -n 200 -u";
+ jftoday = "sudo journalctl -f --since today -u";
lu = "journalctl --user -u";
l = "ls -alh";
ll = "ls -al";
""", ""]
upp = ["util", "exec", "--", "sh", "-c", "jj up && jj git push", ""]
+track-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
+ PR=$1
+ gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
+ set_remote() {
+ jj 2>/dev/null git remote add \"$1\" \"$2\" ||
+ jj git remote set-url \"$1\" \"$2\"
+ }
+ set_remote \(.headRepositoryOwner.login) git@github.com:\(.headRepositoryOwner.login)/\(.headRepository.name)
+ jj git fetch --remote \(.headRepositoryOwner.login) --branch \(.headRefName)
+ jj bookmark track \(.headRefName)@\(.headRepositoryOwner.login)
+ origin=$(gh repo view --json owner,name --jq .owner.login)
+ set_remote \"$origin\" \"$(gh repo view --json sshUrl --jq .sshUrl)\"
+ git fetch --force --update-head-ok \"$origin\" \"refs/pull/'"$PR"'/head:refs/remotes/$origin/pull/'"$PR"'\"
+ "' |
+ sh -euxs
+''', "jj-track-github-PR"]
+
+untrack-github-PR = ["util", "exec", "--", 'sh', '-euxc', '''
+ PR=$1
+ gh pr view --json headRepository,headRefName,headRepositoryOwner $PR --jq '"
+ jj bookmark forget \(.headRefName) || true
+ origin=$(gh repo view --json owner,name --jq .owner.login)
+ git for-each-ref --format \"delete %(refname)\" \\
+ \"refs/remotes/\(.headRepositoryOwner.login)/\(.headRefName)\" \\
+ \"refs/remotes/$origin/pull/'"$PR"'\" |
+ tee /dev/stderr |
+ git update-ref --stdin
+ "' |
+ sh -euxs
+''', "jj-untrack-github-PR"]
# Get all open stacks of work.
open = ["log", "-r", "open()"]
''', 'jj-to']
[revsets]
-log = "@ | trunk()::visible_heads()"
+# Focus current commit, trunk(), on local work and remote work by removing ancestors of trunk()
+log = "@ | trunk() | ancestors_and_children(bookmarks() | tracked_remote_bookmarks()) ~ ..trunk()"
[revset-aliases]
"active(rev)" = "(ancestors(rev) | descendants(rev)) ~ immutable()"
+"ancestors_and_children(x)" = "..x | x::"
+
+# Remote commits not merged in trunk()
+"review(x)" = "ancestors_and_children(remote_bookmarks(x)) ~ ..trunk()"
# Authored or committed by specified user
'user(x)' = 'author(x) | committer(x)'