rossmacarthur / sheldon

:bowtie: Fast, configurable, shell plugin manager
https://sheldon.cli.rs
Apache License 2.0
958 stars 21 forks source link

Extend remote to support `apply` and renaming of files #154

Closed chopfitzroy closed 1 year ago

chopfitzroy commented 1 year ago

Would it be possible to extend the remote option to support renaming of files and using things like apply?

Ideally I would be able to do something like this:

[plugins.sheldon]
remote= "https://github.com/rossmacarthur/sheldon/blob/trunk/completions/sheldon.zsh"
file = "_sheldon"
apply = ["fpath"]

There are a number of repositories that have Zsh completions defined in files with names command.zsh or similar, from my understanding completions must always be defined as _command. A couple of examples:

I was hoping it would be possible to extend remote to support renaming of files and apply.

rossmacarthur commented 1 year ago

So sheldon allows you to configure the install using templates. I'm wondering if that would work for you?

Symlink method

You could symlink the completion file to an existing directory and add that location to the fpath.

# sheldon 0.7.x config file

[templates]
completion = "ln -sf {{ files.0 }} /path/to/completions/_{{ name }}"  # only uses first matched file

[plugins.sheldon]
remote = "https://github.com/rossmacarthur/sheldon/blob/trunk/completions/sheldon.zsh"
apply = ["completion"]

[plugins.bat]
remote = "https://github.com/sharkdp/bat/blob/master/assets/completions/bat.zsh.in"
apply = ["completion"]

[plugins.vcsh]
remote = "https://github.com/RichiH/vcsh/blob/main/completions/vcsh.zsh"
apply = ["completion"]

[plugins.fpath]
inline = "fpath=( /path/to/completions $path )"

You can verify the generated script by running sheldon source manually

chopfitzroy commented 1 year ago

This is amazing! This will absolutely cover my use case.