-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
feat: Support configuration file #139
Comments
I'd say using serde and either TOML (because it's what cargo uses) or YAML (because it's more expressive but still simple). I prefer YAML tbh. There was a previous issue about this, but I'd be fine with writing this from scratch, after a bit more discussion about the details. E.g. I'd want to consider whether it was time to bring #68 back up. |
What do you think about removing ENV_VAR support in favor of a config file? Perhaps either the default installation behavior, or probably more realistically just a (--dump-config ?) command, could be checking if they exist, and generating the initial/default config based on them. definitely yaml or toml would be the obvious choice, and then I guess the choice of crate is even more obvious(serde). so |
I'd probably not want to remove it but rather support both, letting env vars override config options. Also, I'm definitely in favor of serde. |
Would the preferred behavior be that the user can configure their default output completely in the config file? Does this sound like the right track? Another train of thought would be the either config file itself passed as an argument |
Having a default behavior defined in the config file would probably make sense, but I think it would come a bit later.
I've benchmarked loading a yaml config file before in seidr: Even if 80.596 µs is intolerable, people could just not use a config file, and I'm pretty sure the check for its existence wouldn't be an issue. Having the ability to override the default config location is ofc pretty useful, so I'd definetly want to include that. |
That is surprisingly fast.. I didn't think that it would be performance prohibitive necessarily, but that simplifies it for sure. At that point no need to worry about caching/user reloading 👍 I was drafting some of this up to see what it would look like, definitely going to be tricky to integrate, but I am new to the code base. Seeing as you have self assigned it, just let me know if there is something I can contribute. Config options/syntax there are probably a couple different approaches?
Or:
I like that Eza/Exa is kind of an opinionated replacement for LS, I think the overwhelming majority of users are heavy terminal/CLI people who are going to be looking for things like icon support. The config should make it easy to comment out a couple lines and have their output looking good. |
Just to put a pin in this for when I (or some other person doing flake stuff in the far future) gets to it, serde-rs/serde#2538 exists, this might cause issues for our lovely flake (or iterations on it, if we move from naersk to crane or something). Potential starting points for fixes:
welp
I'm still in favor of serde, it's so powerful that it's definitely worth this hassle. Not a lot more hassle thou, but this is fine. |
I'm glad for the suggestion, but on first inspection, I'm not sure any of the 3 options for libraries are at a scale or maturity where I'd feel comfortable introducing them at the moment. That said, I'll try to keep tabs on it and see if other rust projects start using it. |
They kinda lost me right there.. But in all seriousness, it does look interesting. Especially because Zellij and Pop_OS went with them. I am surprised I hadn't heard of this problem with serde. Seems odd that something like that could even occur, you would think everyone would know that it would be an issue... Definitely something to keep an eye on |
https://github.com/serde-rs/serde/releases/tag/v1.0.184
Looks like it might not be a problem |
I'd like to see a config file implemented as well. In the meantime, this is my hack. Step 1 — Add argument handler script.Step 1 runs a script to pass
touch ~/.bin/eza
#!/usr/bin/env zsh
set -euo pipefail
readonly file="$HOME/.ezarc"
readonly opts=("${(f):-$(<"$file")}")
/usr/local/bin/eza "${opts[@]}" "$@"
chmod +x ~/.bin/eza Step 2 — Load default arguments into your config file.
touch ~/.ezarc
--all
--colour=always
--git
--git-ignore
--group-directories-first
--icons
--long
--time-style=iso Step 3 – Update
|
Copy-pasting what I wrote at the time in ogham/exa#511 (comment), whit a few modifications. Here’s a suggested, hypothetical config file, inspired by ui_styles.rs/default_theme.rs:
|
I think I've heard a lot that some people do desire the ability to make a default command. EDIT: nvm I am was too fast to think about what I was saying >_< |
That's a pretty puzzling position to take, tbh... Shell aliases are rather a hacky way to alter the default behaviour of another program, unless it is is very specifically related to it working properly with that shell. With that said even then I think you'd normally resort to environment variables first if an option... It is of course rather a matter of opinion but I've personally never really liked relying on aliasing from my shell. Mostly just my taste in organisation, but there are the rare odd corner cases which cause trouble long after you have forgotten you've aliased a command... I personally think most programs should have robust options for configuring all their default params, and I would almost always favour a hierarchy following something like the de facto standard:
As I say, this is certainly somewhat opinion based, but it is also a clear hierarchy heading from global -> specific behaviour at each step. |
This reminds me that I made the .theme file work this way, I think ENV variables should take priority even from just a backwards-compatability perspective. Also, currently just have |
Well traditionally, basic shell utilities like I guess a few behavior things could be configured in a config file but then it raises the question of: how useful is it to be able to control behavior in another way vs added complexity, when there’s already a feature that does just that pretty well. But ultimately I don’t really care if users can configure their theming easily in a config file. |
A note on aliases: I recently made the transition to shell The difference between alias and abbreviation is that the latter will be replaced by the full command after pressing enter/space. Nothing is hidden or abstracted from either the user or the shell history. It also helps the user to learn and remember commands they've abbreviated, so the use of abbreviations is not hampering your ability to proficiently operate outside of your machine. That being said, it would not be ideal to flood the terminal with an abbreviation that turns the characters My 2c is that a config file certainly worth having, because the environment is fairly fluid while a config file is reliably static. Plus, sample config file with lots of comments also doubles as quick documentation reference- I always appreciate it when projects do that. I personally vote toml > yaml. For whatever reason, I find yaml really difficult to make visual sense of. Moreover- users are going to be sharing configs via copy/paste. Be it reporting bugs here in github issues, asking for help over chat programs, "show off your config" discussion threads. Whitespace is highly susceptible to being mangled in a lot of copy/paste contexts, so avoiding the whitespace sensitive yaml in this context would be prudent. |
Also just to make sure we're all on the same page, I feel features like abbreviations are better left to the shell, there is some level of separation of concerns here that would make sense to uphold, it wouldn't ultimately be eza's job to recreate a fully featured terminal experience in place of the actual shell that's normally tasked with providing these features. |
The above is not meant to suggest eza should handle abbreviations, it's a continuation of the conversation around aliases, and how a config file is beneficial even while aliases/abbreviations exist. |
In checking out LSD earlier today before I eventually found my way here.
one of the first things that sticks out is their support for a config file (I believe they use yaml)
I think it's a decent longer term goal, as it allows for sharing of "themes" between users and doesn't require ENV VAR="ga;23", etc etc
If that is something the project is interested in, the first thing would probably be to decide on what format and therefore what crates to use.
The text was updated successfully, but these errors were encountered: