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

env var BAT_OPTS #310

Closed
VladimirAlexiev opened this issue Sep 13, 2018 · 8 comments
Closed

env var BAT_OPTS #310

VladimirAlexiev opened this issue Sep 13, 2018 · 8 comments
Labels
feature-request New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@VladimirAlexiev
Copy link

BAT_THEME allows you to set a theme.
I also want to set --wrap never permanently, but there's no respective env var.

Why not do like "less", where the LESS env var can take any of the command-line options?
I'd suggest to use the name BAT_OPTS for this, since in the mind of Windows users BAT means "batch files".

(Note: I've added this setting to your bat() function as per #263)

@eth-p
Copy link
Collaborator

eth-p commented Sep 14, 2018

@VladimirAlexiev I agree, something like this would be useful. Some options such as --color and --wrap don't currently have environment variables, and future options would need their own respective variables as well.

That being said, however, I think that it might be getting a bit excessive on environment variables. We already have:

  • BAT_STYLE
  • BAT_THEME
  • BAT_TABS
  • BAT_PAGER

Maybe there's a better way to support this kind of functionality? I'm thinking there should be some sort of configuration file (toml, maybe?) that covers all of these different options, and any future options that could be added. @sharkdp What do you think?

@sharkdp sharkdp added feature-request New feature or request help wanted Extra attention is needed question Further information is requested labels Sep 16, 2018
@sharkdp
Copy link
Owner

sharkdp commented Sep 16, 2018

I agree that the number of environment variables is getting out of hand and I'd rather replace it with one of the suggested options (BAT_OPTS or configuration file).

The BAT_OPTS variable is kind of appealing to me since it is really easy to implement (I believe, if clap supports this somehow 😄) and very straightforward to use. There is no need for additional documentation of a config format and N other environment variables - everything is just configured by command-line options, but they may also be placed in BAT_OPTS.

A dedicated configuration file would have the advantage that some things might be easier to configure (for the user) and potentially easier to parse/deserialize (for the developer). I'm thinking about features such as #169 where it might be more convenient to have a dictionary-type structure in a configuration file as opposed to a command line flag which has to be specified multiple times (--map-extension myini ini --max-extension my-ruby-file rb).

Note that there is a hybrid variant which ripgrep uses where command line flags are stored in the configuration file.

@llimllib
Copy link

llimllib commented Oct 3, 2018

(To add some detail to @VladimirAlexiev's comment, in case you got here looking for how to tell bat to never wrap like I did, here is one way to do so. Add this alias to your ~/.bashrc until there is some mechanism to tell bat not to page:

# Add the `--wrap never` arg to all `bat` invocations
bat() {
    command bat --wrap never "${args[@]}"
}

)

@sharkdp
Copy link
Owner

sharkdp commented Oct 3, 2018

@llimllib Not sure what kind of syntax this is, but that doesn't seem to work for me in bash or zsh. Simply setting an alias should be enough:

alias bat="bat --wrap never"

@sharkdp
Copy link
Owner

sharkdp commented Oct 7, 2018

Support for a ripgrep-style configuration file: #338

@llimllib
Copy link

llimllib commented Oct 8, 2018

@sharkdp that function works for me in bash, maybe you need to update? anyway the simple alias is obviously simpler and better 👍

@sharkdp
Copy link
Owner

sharkdp commented Oct 17, 2018

Both BAT_OPTS as well as a configuration file have been added in #338.

@sharkdp sharkdp closed this as completed Oct 17, 2018
@sharkdp
Copy link
Owner

sharkdp commented Oct 17, 2018

Released in v0.8.0.

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 help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants