jj icon indicating copy to clipboard operation
jj copied to clipboard

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

Open ShuP1 opened this issue 2 years ago • 3 comments

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

ShuP1 avatar Nov 08 '23 08:11 ShuP1

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

necauqua avatar Nov 08 '23 11:11 necauqua

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).

martinvonz avatar Nov 08 '23 14:11 martinvonz

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

necauqua avatar Nov 08 '23 18:11 necauqua

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

avamsi avatar Apr 05 '24 10:04 avamsi

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

necauqua avatar Apr 05 '24 11:04 necauqua