Persistent zed preferences (aka ".zedrc")
In keeping with what users often expect from UNIX command-line tools, it has been proposed that zq should have smart defaults for what happens when it's invoked with few/no arguments. However, the definition of what's "smart" might be quite different based on a user persona or use case. That is, our idea of a sensible default might not match theirs. To give a few examples:
-
A user that works largely in a particular data format (NDJSON, Parquet, ZSON, etc.) might want to always have zq output that format without having to specify a
-foption. -
Likewise, a user that is always reading files of a particular input format that doesn't happen to be supported by the auto-detection (e.g. Parquet) might want to always have
zqattempt to input in that format without having to specify the-ioption. -
A user may have user-defined functions, user-defined operators, or
const/typevalues they always want applied as if they'd invoked them via the-Ioption. -
A user running on a system with excess resources may want a consistently raised ceiling for
-sortmemand/or-fusememparameters. -
A user with preferences for epoch timestamps may want the
-Eoption consistently applied (this was discussed in the context of an issue from the community #1002 where the user expressed support for the concept of persistent preferences, but in that case we addressed the user's primary concern by just moving to ISO timestamps by default for all relevant formats.)
There's surely multiple ways we could implement this. An approach I’d put on the table in the past would be something similar to $HOME/.gitconfig, since it provides a readable text-based summary of the current preferences along with its companion git config that allows for easy viewing/setting of values. That said, given the push toward cloud-friendly tooling, something YAML-based has also been proposed.
@mccanne pointed out that the changes proposed in #2586 will make it easier for us to implement these persistent preferences, since having one set of global flags means there's no need to maintain complicated hierarchical config about which flags apply where.
After learning about user-defined operators a and user-defined functions a community user recently mentioned in a Slack thread how handy this would be. In their own words:
Would be neat if there was a ~/.zedrc where you could autoload user-defined functions