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

Add completions for git blame command #3094

Merged
merged 1 commit into from Jun 2, 2016
Merged

Conversation

Hunsu
Copy link
Contributor

@Hunsu Hunsu commented May 31, 2016

I would like to know how to test it.

@faho
Copy link
Member

faho commented May 31, 2016

Thanks for doing this!

I would like to know how to test it.

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

I'm gonna add some more comments inline.

complete -f -c git -n '__fish_git_needs_command' -a blame -d 'Show what revision and author last modified each line of a file'
complete -f -c git -n '__fish_git_using_command blame' -s b -d 'Show blank SHA-1 for boundary commits'
complete -f -c git -n '__fish_git_using_command blame' -l root -d 'Do not treat root commits as boundaries'
complete -f -c git -n '__fish_git_using_command blame' -l show-stats -d 'Include additional statistics at the end of blame output'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "of blame output" is a bit redundant.

@faho
Copy link
Member

faho commented May 31, 2016

For all the options that take a file, you'll want to replace the "-f" with a "-r" - they require an argument, and it can be a file - see complete --help.

These are "-S" and "--contents", for "--date" you'll probably want "-x" (no files but a required argument). Though that's another shared option (with git log again).

@faho faho self-assigned this May 31, 2016
@Hunsu
Copy link
Contributor Author

Hunsu commented May 31, 2016

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

That's what I did but I got an error about string not recognized.

I'm gonna add some more comments inline.

Thanks, I will fix the issues.

@faho
Copy link
Member

faho commented May 31, 2016

That's what I dif but I got an error about string not recognized.

You're using completions from 2.3.0 but a fish before that. The string builtin is new in 2.3.0, so you'll want to upgrade to that.

@faho faho merged commit 24d6f6d into fish-shell:master Jun 2, 2016
@faho
Copy link
Member

faho commented Jun 2, 2016

Merged, thanks!

We probably want to add some more stuff here, but as a first pass it's not bad.

@Hunsu
Copy link
Contributor Author

Hunsu commented Jun 2, 2016

We probably want to add some more stuff here, but as a first pass it's not bad.

What more stuff do you want to add? I will look at the TODO to improve the completions for git. I read somewhere that fish shell's auto-completion uses man pages, is it true? If so why it doesn't work for git (or the other commands).

@faho
Copy link
Member

faho commented Jun 2, 2016

I read somewhere that fish shell's auto-completion uses man pages, is it true?

You possibly read it on fishshell.com - it is true. We have a python script that tries to parse man pages and generate completion scripts from that. For simple stuff (commands that take files and only have long and short options that don't take arguments) it works, but for something like git man pages just aren't written in a precise enough format that it could do much. Even for simple stuff the descriptions are often "Something something something...[See the man page for details]".

So we have a lot of hand-written completions, which includes git (as you've probably seen).

What more stuff do you want to add?

Well, the arguments. From the man page, it appears git blame takes a "rev" and also files. We're not currently completing the "rev" part (which, in simplified terms, is a git-ism for those commit hashes you see all over the place).

Then we have the options that take arguments we're not completing yet, like "--encoding". We're also not yet sharing the shared options.

This is complicated stuff, and some of it might well be impossible with our current system - e.g. completing "dates", because there's an infinite number of them.

@zanchey zanchey added this to the next-2.x milestone Jun 6, 2016
@krader1961 krader1961 modified the milestones: fish 2.3.1, next-2.x Sep 4, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants