martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.07k stars 264 forks source link

FR: zsh completion `ff move --to <TAB>` #2550

Open ShuP1 opened 9 months ago

ShuP1 commented 9 months ago

Is your feature request related to a problem? Please describe. With zsh completion and git commit --fixup <TAB>, I get a list of previous commits. It is not the case with ff move --to <TAB>

This tiny issue makes git better for this workflow IMO vs ff log + copy-paste

Describe the solution you'd like Add completions listing N previous commits

Describe alternatives you've considered Got back to git

necauqua commented 9 months ago

This is blocked on clap dynamic completion 🤷 Slight duplicate of #1217 - I'm sure some revset of last commit change ids will definitely be added to completion once that's possible

+ copy-paste

Depending on the size of the repo, the unique short prefixes of change-ids/commit-ids are often good enough to avoid mouse copy-pasting

I mean you could handwrite a completion script, like cargo does, or guys at nushell carapace do for jj, so it's not a hard hard blocker

martinvonz commented 9 months ago

You might also be able to use use https://github.com/rsteube/carapace-bin. It has support for jj since the latest release (0.28.3).

necauqua commented 9 months ago

Ah yes I thought this thing was nushell-specific, I meant it exactly :)

avamsi commented 4 months ago

I use the following snippet with fzf (https://github.com/avamsi/dotfiles/blob/5b94015cc062aa0c1fd8ca94e32d0aa17bd70415/.zshrc#L63-L75):

_fzf_complete_jj() {
    _fzf_complete \
        --preview 'jj bgc show --summary {1}' \
        --preview-window wrap -- "$@" < <(
            jj bg list --revisions=interesting --template=oneline
        )
}

_fzf_complete_jj_post() {
    cut -d ' ' -f1
}

bg, bgc and list are my custom jj aliases (https://github.com/avamsi/dotfiles/blob/5b94015cc062aa0c1fd8ca94e32d0aa17bd70415/.jjconfig.toml#L8-L10)

screenshot

necauqua commented 4 months ago

I just realized nothing stops us from appending (a couple of most useful) manually written completions to the output of jj util completion