jjui icon indicating copy to clipboard operation
jjui copied to clipboard

FR: Move nearest bookmark to `@-` aka tug

Open gozes opened this issue 2 months ago • 3 comments

Is your feature request related to a problem? Please describe.

my jj workflow mostly revolve around injecting commits around @- with a description to keep them focus and then squashing changes into @- or commits around it to build "a stroy" for my change. the bookmark should always be on @- before being push. The current way the jjui work I have to always do b then m to move the bookmark to @-

in my jj config I have the following to accomplish this

[revset-aliases]
'closest_bookmark(to)' = 'heads(::to & bookmarks())'
'closest_pushable(to)' = 'heads(::to & mutable() & ~description(exact:"") & (~empty() | merges()))'


[aliases]
tug = ["util", "exec", "--", "sh", "-c", """
if [ "x$1" = "x" ]; then
  jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
else
  jj bookmark move --to "closest_pushable(@)" "$@"
fi
""", ""]

Describe the solution you'd like

  • jjui ship with a propose keymap of b follow by t that will move the nearest bookmark to @- in the case of more the one bookmark being pick up to move pop up a window to select the one bookmark to move to @-

Describe alternatives you've considered

none

Why current features fail to cover this request

  • moving a bookmark to @- is a multi step process which given how often I do this is not ideal

Additional context

the above workflow allows my AuADHD 🧠 to build the change in whatever way my 🧠 want to go about it at the same time allows me to build a story to make it easier for the reviewers to follow a 🧵 of changes

gozes avatar Oct 16 '25 09:10 gozes

Hey, thanks for the suggestion.

With the current version of jjui, even though it doesn't support multi key presses, you should be able to do this by using a custom command. However, there's a small issue that's preventing the following command to run successfully, I am going to push a fix for that momentarily.

"tug" = { key = ["T"], args = ["tug"] }

For v0.10, this will be possible with the following configuration:

[actions."tug"]
desc = "Tug the current commit to the working copy"
id = "run"
jj = ["util", "exec", "--", "sh", "-c", """
if [ "x$1" = "x" ]; then
jj bookmark move --from "closest_bookmark(@)" --to "closest_pushable(@)"
else
jj bookmark move --to "closest_pushable(@)" "$@"
fi
"""]
next = ["refresh"]

[bindings]
revisions = [
    { on = ["b", "t"], do = "tug" },
]

idursun avatar Oct 17 '25 22:10 idursun

Given I already have the tug command/alias/what have you in my config can jjui not let me have a "custom command that just calls jj tug under the hood and bind it to a key? I not looked at the codebase to work out how you are calling jj commands put I would a assume that as long as the command/alias exist it would just excused in jj and give jjui the output no?

gozes avatar Oct 17 '25 22:10 gozes

hey @gozes

Given I already have the tug command/alias/what have you in my config can jjui not let me have a "custom command that just calls jj tug under the hood and bind it to a key?

i think you can already do that with jjui. like you said, i have tug alias set up in jj/config.toml and only this line in jjui/config.toml:

"tug" = { key = ["alt+t"], args = ["tug"] }     

and it works just fine when i press alt+t in jjui

demo:

asciicast

baggiiiie avatar Oct 19 '25 06:10 baggiiiie