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

utility command to add customizations #1266

Open
rsteube opened this issue Oct 5, 2020 · 5 comments
Open

utility command to add customizations #1266

rsteube opened this issue Oct 5, 2020 · 5 comments
Labels
feature-request New feature or request

Comments

@rsteube
Copy link
Contributor

rsteube commented Oct 5, 2020

adding customizations is easy enough after one has understood the concept, but having a util command that invokes git would be nice (e.g. bat --add-syntax git://..)

related #948

@rsteube rsteube added the feature-request New feature or request label Oct 5, 2020
@eth-p
Copy link
Collaborator

eth-p commented Oct 5, 2020

If you don't mind using an external repo, I have something for things like this in my bat-extras repo. It's currently experimental (and thus undocumented), but it should work fine:

https://www.github.com/eth-p/bat-extras/tree/master/src%2Fbat-modules.sh

It builds just like any of the other bat-extras scripts, and you can use it with bat-modules --setup followed by bat-modules --update.

The config file syntax is as follows:

syntax URL
    checkout REF  # Defaults to master if omitted.

And URL can be any of the following:

  • user/repo
  • gitlab:user/repo
  • An HTTP or SSH URL to a git repository

It should work fine on MacOS, Linux, and WSL 2. I haven't tested MSYS2/Cygwin/GitBash, but if it has all of the common gnu coreutils, it will probably work too.

@eth-p
Copy link
Collaborator

eth-p commented Oct 5, 2020

After reading #1262 and then this, you've given me a pretty interesting idea.

@sharkdp, would you be open to the idea of hosting a community-driven repo of themes and syntaxes?

If so, we could add a command like bat cache community [un]install [theme|syntax]-NAME, which would download and install a theme or syntax from a folder inside a repo named shark-dp/bat-community. It would be a more central repository for additional themes and syntaxes, but would also come with no guarantee of stability.

Doing something like this could also let us move some of the more obscure syntaxes we include into the community repo, and help reduce startup time. Better yet, we could strip it down to the bare minimum and have bat install syntaxes on demand!

Or if that seems a bit too far out of bat-as-a-command's scope, I could probably create an external Python script (or Homebrew repo) exactly for something like this.

@keith-hall
Copy link
Collaborator

Potentially related to that idea: #919

@sharkdp
Copy link
Owner

sharkdp commented Oct 5, 2020

I would have to think about this a bit more, but it sounds like a cool idea.

Two points that come to my mind right now:

  • The one thing that I really think is a big advantage of bat over using something like vim as a previewer for files is actually the large set of builtin syntaxes (Builtin in the strongest sense: they are inside the bat binary). This is the reason why I was pretty open to including new syntaxes (but we had to put some kind of restriction). Once we start to have a second place with syntaxes, that advantage (and feeling 😄) of having everything inside a single binary is somehow gone and things would feel more like a text editor where I need to install plugins.
  • We should think about how this could work together with Share sublime syntaxes #919 (@keith-hall was faster)

@eth-p
Copy link
Collaborator

eth-p commented Oct 5, 2020

#919 could definitely meet the criteria for the repository of syntaxes/themes. I have two concerns with that, though:

  1. It should have a metadata file for extension and first-line to syntax mappings. If we were to ever implement automatic syntax downloads (which would be extremely nice), bat would need a way to determine the correct syntax to install without downloading all of them.

  2. Downloading all the syntaxes only to install a single one of them would be a waste. Ideally, the repo would mostly contain submodule references, which can be cloned on an as-needed basis.

The one thing that I really think is a big advantage of bat over using something like vim as a previewer for files is the large set of builtin syntaxes (Builtin in the strongest sense: they are inside the bat binary). This is the reason why I was pretty open to including new syntaxes (but we had to put some kind of restriction).

That could likely be solved with the automatic syntax download idea. I suppose we should also be mindful of the rare cases where bat is used without internet, though. Either way, we definitely should do a poll if we ever plan remove any built-ins.

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

No branches or pull requests

4 participants