Skip to content

Add full zsh completion support - #727

Closed
mikkeloscar wants to merge 1 commit into
git-lfs:masterfrom
mikkeloscar:zsh-completion
Closed

mikkeloscar wants to merge 1 commit into
git-lfs:masterfrom
mikkeloscar:zsh-completion

Conversation

@mikkeloscar

Copy link
Copy Markdown

This adds full zsh completion support for git-lfs. I have used the same file structure as the other PR for bash support. Let me know if I should change it in any way.

This version depends on the _git completion distributed with zsh, and it should be installed into something like: /usr/share/zsh/site-functions/_git-lfs.

@technoweenie

Copy link
Copy Markdown
Contributor

Hey, this is awesome, especially since I use zsh :) This is a good start, but I'd really like Git LFS to generate this somehow. I'm going to hold off on this until Git LFS v1.1 though, so we can figure out how users can install this.

@technoweenie technoweenie mentioned this pull request Oct 19, 2015
7 of 13 tasks
@technoweenie technoweenie mentioned this pull request Nov 19, 2015
16 of 17 tasks
@sinbad

sinbad commented Apr 5, 2016

Copy link
Copy Markdown
Contributor

As a new zsh user, I really liked that way I could just add support for many things like go via http://ohmyz.sh/ plugins. I wonder if we should have a way to generate a zsh config which can be submitted as a plugin there, with maybe an entry point for custom installs as well (but which has to be manually configured)?

@technoweenie

Copy link
Copy Markdown
Contributor

There are a couple problems here. First, the commands are doomed to be out of perpetually out of date. Second, what's installation like? "clone the repo down and copy to some directory owned by root"?

I'm cool with shipping this now, with updated descriptions and command flags. But I think it'd be worth building it into the command:

  1. Turn this into a template that Git LFS can generate from the commands package.

  2. Add command to install to something in $fpath

  3. Add command to install for oh-my-zsh as @sinbad suggested. Maybe even submit to https://github.com/zsh-users/zsh-completions.

  4. Teach git lfs install/update how to update this. Maybe store the location in git config:

    $ git config --global lfs.etc.zshautocomplete
    /Users/rick/.zsh/site-functions/_git-lfs

Also, is there any way to get this to trigger for git lfs?

FWIW I happened to stumble on this project: https://github.com/bobthecow/git-flow-completion. Might be a good example that we can borrow from for bash/fish autocompletion :)

EDIT: Bonus points if we somehow be added to git's autocompletions :)

$ git l<tab>
$ git log # :(

@sinbad

sinbad commented Apr 6, 2016

Copy link
Copy Markdown
Contributor

👍 Thinking about this overnight I was also thinking this should just be an lfs command (git lfs zsh?) to generate the script, and that it should do it from the command data we already have in cobra so that it doesn't need to be manually updated. Suggested options:

Bonus points if we somehow be added to git's autocompletions :)

Yeah, wonder if we need to send PRs to both core Git, http://ohmyz.sh/ and https://github.com/zsh-users/zsh-completions or whether there's a more efficient way?

@sinbad

sinbad commented Apr 6, 2016

Copy link
Copy Markdown
Contributor

@technoweenie

Copy link
Copy Markdown
Contributor

I believe $ZSH_CUSTOM is an oh-my-zsh thing. With plain .zsh, autocompletions are loaded as a site function in a directory defined in $fpath. The filename $fpath/_git-lfs seems to be significant, linking the autocompletions to git-lfs, but not git lfs. I think we can just use $fpath, and tell the user how to update it in their .zshrc if there's a problem adding the file.

Instead of git lfs zsh, how about something like git lfs integrate zsh? This would be a good spot to add other integrations, like bash, in the future. It should automatically detect oh-my-zsh if possible. If not, then we can add git lfs integrate oh-my-zsh or something.

I've been exploring generating a script using this as a template

Would you mind throwing that on top of this PR? I want to include @mikkeloscar's work here in the commit list, since we're taking a lot of inspiration from it.

@sinbad

sinbad commented Apr 6, 2016

Copy link
Copy Markdown
Contributor

I believe $ZSH_CUSTOM is an oh-my-zsh thing

Yeah that's what I was trying to use as a trigger to assume oh-my-zsh if given no other context.

The filename $fpath/_git-lfs seems to be significant, linking the autocompletions to git-lfs

So if $fpath is specified, I just default to $fpath/_git-lfs with no .zsh ext? I'll probably need you to verify this works in practice once I do...

Would you mind throwing that on top of this PR? I want to include @mikkeloscar's work here in the commit list, since we're taking a lot of inspiration from it.

Oh yeah that's an excellent idea. Rebased & done.

@sinbad

sinbad commented Apr 6, 2016

Copy link
Copy Markdown
Contributor

how about something like git lfs integrate zsh?

That's a good shout too, I'll do this once I've figured out a couple of other niggles.

@sinbad sinbad mentioned this pull request Apr 8, 2016
@sinbad

sinbad commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

New PR at #1133

@mikkeloscar

Copy link
Copy Markdown
Author

Hello, I just wanna say that I have been following the discussion here and it's fine by me if you close this PR when you want to :)

Also, I'm glad that you could use some of the stuff from this PR.

@sinbad

sinbad commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

Thanks! If you have any ideas of how to add completions for git lfs (i.e. with a space rather than git-lfs), I'd love to hear them at #1133, I totally failed when I tried to adapt the script :)

@sinbad sinbad closed this Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants