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
Conversation
Thanks for doing this!
You copy the file into a directory in $fish_complete_path, e.g. 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' |
There was a problem hiding this comment.
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.
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 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 |
That's what I did but I got an error about
Thanks, I will fix the issues. |
You're using completions from 2.3.0 but a fish before that. The |
Merged, thanks! 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). |
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).
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. |
I would like to know how to test it.