Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 [Question] no autocompletion for second path #1167

Closed
TornaxO7 opened this issue Aug 20, 2022 · 7 comments · Fixed by #1561
Closed

🚀 [Question] no autocompletion for second path #1167

TornaxO7 opened this issue Aug 20, 2022 · 7 comments · Fixed by #1561

Comments

@TornaxO7
Copy link

TornaxO7 commented Aug 20, 2022

Hi! delta needs two paths obviously to get the diff of them. Normally I'm using <tab> in my shell to get a nice autocompletion for the files. However, the autocompletion only works for the first argument/path but not for the second, is that behaviour expected?

Example interaction (how it is)

ls

deletus.txt yeet.txt

delta de<tab> results to delta deletus.txt but delta deletus.txt ye<tab> results to delta deletus.txt ye.

I expected an expansion to delta deletus.txt yeet.txt.

@dandavison
Copy link
Owner

dandavison commented Aug 20, 2022

Hi @TornaxO7, are you trying to use the completion config files in the delta repo (etc/completion/*), or are you using special delta completions installed by your package manager? (it would be understandable if you weren't sure of the answer to this second question)

If so, the short answer is that the file for bash, I honestly don't know whether it works. I think that what's committed is my first attempt at it, and I never went back to it, and honestly I don't know anything about how to write bash completions. So perhaps that should be deleted from the repo? I just tried to source it and it seemed broken to me.

The file for zsh however might do something sensible.

And the file for fish I bet works, since it was created today by someone who knows about fish.

So, if you're using any of those files in etc/completion/*, that's the story -- I'd love help with this, especially for bash, and if the answer is that file should be deleted then let's do it.

On the other hand, if you haven't got any completion special files installed for delta, then I would have thought that your shell would complete file paths in the first and second position by default. (What shell are you using?)

Sorry this answer isn't more satisfactory!

@TornaxO7
Copy link
Author

Sorry for my late reply!

Sorry this answer isn't more satisfactory!

Don't worry I prefer to have at least an answer than nothing ^^

Hi @TornaxO7, are you trying to use the completion config files in the delta repo (etc/completion/*), or are you using special delta completions installed by your package manager?

I'm using arch linux and installed delta with pacman and did nothing else.

(What shell are you using?)

I'm using zsh

@latipun7
Copy link

I'm using zsh

#1022

@maverick1872
Copy link

Just echoing @TornaxO7; I'm in the exact same situation. ZSH and installed via Pacman.

@joshuataylor
Copy link

A workaround I've ended up using for zsh is adding compdef _gnu_generic delta to my .zshrc.

Though you could put it anywhere, as long as zsh references it. I have mine in a special "this fixes zsh issues" file I source ;).

I also have a similar issue with lxc/lxd, which I came to a similar solution with.

The reason this probably works is that it overrides previous completions? 🤷

Tested and confirms it works on zsh 5.9.x+.

MacOS Ventura Apple Silicon works, using latest head from brew (zsh 5.9.0.1-dev (arm-apple-darwin22.6.0))

And tested on zsh 5.9.x on Linux (I use arch btw). zsh 5.9.0.1-dev (x86_64-pc-linux-gnu)

@maverick1872
Copy link

Finally got around to looking at this a little bit. The following seems to work in my testing so far. This corrects it so that that it expects at most two files and will provide proper completions for both of them. I've only included a small subset of the flag options though since I didn't want to go through the effort (yet) for adding all of them.

# Filename: _delta

#compdef delta

_arguments \
  '-s[Side-by-side view]' \
  '-n[Display line numbers]' \
  '-w[Width of the under/over line decorations]' \
  '-h[Show help message]' \
  '-V[Show version information]' \
  '--tabs[Number of spaces to be used in place of tab characters]' \
  '--dark[Use colors appropriate for a dark teminal color theme]' \
  '--light[Use colors appropriate for a light terminal color theme]' \
  '1:filename:_files' '2:filename:_files'

@dandavison
Copy link
Owner

Thanks @maverick1872, I agree with your comment elsewhere that the automatic completion generation in #1561 seems like the right path forwards. This issue will close when that merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants