-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdot_jj_aliases
More file actions
106 lines (90 loc) · 3.15 KB
/
dot_jj_aliases
File metadata and controls
106 lines (90 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*-mode:sh-*- vim:ft=bash
# ~/.jj_aliases
# =============================================================================
# Shell aliases and helpers for Jujutsu (jj). jj is the primary VCS.
#
# Reference: https://docs.jj-vcs.dev/latest/
# Core ops
# =============================================================================
alias j='jj'
alias js='jj status'
alias jl='jj log'
alias jla='jj log -r "all()"'
alias jls='jj log -r "stack()"'
alias jd='jj diff'
alias jdc='jj diff -r @'
alias jsh='jj show'
# Commit shaping
# =============================================================================
alias jn='jj new'
alias jde='jj describe'
alias jsq='jj squash'
alias jsp='jj split'
alias jab='jj absorb'
alias je='jj edit'
alias jaban='jj abandon'
# Navigation
# =============================================================================
alias jnext='jj next'
alias jprev='jj prev'
# Bookmarks (branches)
# =============================================================================
alias jb='jj bookmark list'
alias jbc='jj bookmark create'
alias jbm='jj bookmark move'
alias jbd='jj bookmark delete'
# Remotes (git backend)
# =============================================================================
alias jf='jj git fetch --all-remotes'
alias jp='jj git push'
alias jpa='jj git push --all'
# Sync: fetch all remotes and rebase current stack onto trunk.
# Replaces the `gpa` muscle memory from git_aliases.
alias jsync='jj git fetch --all-remotes && jj rebase -d "trunk()"'
# Rebase
# =============================================================================
alias jrt='jj rebase -d "trunk()"'
# Undo / op log
# =============================================================================
alias ju='jj undo'
alias jol='jj op log'
alias jor='jj op restore'
# Conflicts
# =============================================================================
alias jcon='jj log -r "conflicts()"'
alias jres='jj resolve'
# Revset-based views
# =============================================================================
alias jready='jj log -r "ready()"'
alias jwip='jj log -r "wip()"'
alias jopen='jj log -r "open()"'
# Workspaces
# =============================================================================
alias jwl='jj workspace list'
alias jwa='jj workspace add'
# Helpers
# =============================================================================
# Describe @ with a message and open a fresh working copy on top.
# Usage: jcommit "feat(foo): bar"
jcommit() {
jj describe -m "$1" && jj new
}
# Create a bookmark at @ and push it, tracking the remote.
# Usage: jnewbranch my-feature
jnewbranch() {
jj bookmark create "$1" -r @ && jj git push --bookmark "$1"
}
# Full sync: fetch, rebase onto trunk, push current bookmark.
jfullsync() {
jj git fetch --all-remotes && jj rebase -d "trunk()" && jj git push
}
# fzf-backed commit picker: select a commit to `jj edit`.
if command -v fzf >/dev/null 2>&1; then
jfe() {
local commit
commit=$(jj log --no-graph -T 'change_id.short() ++ " " ++ description.first_line() ++ "\n"' \
| fzf --preview 'jj show -r {1}' \
| awk '{print $1}')
[ -n "$commit" ] && jj edit "$commit"
}
fi