Declarative Configuration Command
Hello! I've recently started using Tide and absolutely love it. 😁
Like several others (1, 2, 3), I manage my system-wide configuration using a dotfiles repository. Because of Tide's reliance on uvars, it isn't quite compatible with how most people configure fish with their dotfiles (set some global vars in config.fish or a conf.d script).
You've made it clear that you're not interested in supporting declarative configuration through a file (beyond overriding the uvars set by Tide). Even though it's not personally convenient, I completely understand this decision given the ease and user-friendliness of the wizard.
It is currently possible to run tide configure in a declarative way, though, which can easily be integrated into most peoples' dotfiles setup (since most have the concept of an "install script"). I'm currently doing it like this:
tide configure <(string join '' 2 2 1 3 3 4 1 1 1 y | psub) 1>/dev/null
This is simply running the configuration wizard with my pre-selected choices and hiding any output. This allows me to integrate it into my environment initialization and synchronization workflow that I use across multiple computers. The issue is that it's not very readable (the choices are just numbers), and it's quite brittle (a menu order change would break this command in unpredictable ways).
So, in lieu of having a declarative configuration file, I was wondering if it would be possible to enhance the tide configure sub-command (or add a new sub-command) that can declaratively and non-interactively change the configuration. I'm envisioning something like this:
tide declarative-configure \
--style classic \
--colors 16 \
--time no \
--separators slanted \
--heads slanted \
--tails slanted \
--height 1 \
--spacing compact \
--icons few
This command would have no choice prompts, and its exit status would indicate whether setting the configuration was successful (since different values and combinations of choices could be invalid).
An additional option could be added to the last step of the configuration wizard to print out a declarative configuration command for the options that were just chosen. Something like this:
Overwrite tide config?
(y) Yes
(r) Restart from the beginning
(c) Quit and print a declarative configuration command
(q) Quit and do nothing
Choice [y/r/c/q]
I definitely haven't thought through the naming/verbiage of this feature, but I think the functionality could be really nice. It would satisfy the desire many users have for an ergonomic way to do declarative configuration, and it wouldn't require any changes with Tide's underlying architecture (reliance on uvars).
Even still, I realize this is not a small feature request, so I can understand if you don't want to take this on. If you're not interested in implementing it, would you be open to a pull request?
This is a great idea! Tide is already intended to be configured through install scripts, but first you have to go through the wizard. Why not just add the wizard to the install script! I love it, this would really improve the Tide configuration story ❤️
I'm definitely willing to take this on, and seeing as this is a fairly delicate thing that I will have to maintain indefinitely, I don't think I'd entrust this to anyone else 😄
EDIT: P.S.
tide configure <(string join '' 2 2 1 3 3 4 1 1 1 y | psub) 1>/dev/null
can be more simply expressed as
echo 2 2 1 3 3 4 1 1 1 y | tide configure >/dev/null
I ran into this myself today... trying to figure out how to include tide in my dotfiles. Only to discover that the configuration is in uvars from the interactive configuration, instead of a config file or including global vars within the config.fish file.
I updated my dotfiles script for fish to include tide configuration with:
echo 1 1 3 2 2 2 2 2 y | fish -c 'tide configure' >/dev/null
The only risk I can see with this command, is if/when the configuration changes in the future (adding/removing/modifying or changing the order of the current interactive config). If/when that happens, I'll need to update my command within my script.
These hack-y echo methods are not great... If tide configure changes, then you can get stuck with a blank/hung terminal if you don't have enough settings in the echo and the command sits there waiting for input. Yes, you can ctrl+c out of it, but it's still just a crappy way of doing it. Something truly declarative (that also picks defaults automatically for any missing arguments) would be much better.
As of the time of this comment, this is the command you'd want to use:
echo 2 1 2 3 1 1 1 1 1 1 y | tide configure &> /dev/null
I don't really understand the resistance to using a proper config file instead of universal variables. It would just be a matter of changing this:
https://github.com/IlanCosman/tide/blob/447945d2cff8f70d5c791dd4eec8b322d37798dd/functions/tide/configure/choices/all/finish.fish#L25
to echo "set -g ..." >> ~/.config/fish/conf.d/tide.fish, emptying the file before, and sourcing it after. It wouldn't even affect existing installs since these get loaded after universals anyways (and if you really wanted, you could add a line to remove any existing universals)
My shell takes about 180ms to startup, and only 3ms of that is sourcing my tide.fish file, most of which comes from tide configure:
> time fish -c exit
________________________________________________________
Executed in 179.24 millis fish external
usr time 37.47 millis 0.85 millis 36.62 millis
sys time 70.86 millis 1.72 millis 69.14 millis
> time source ~/.config/fish/conf.d/tide.fish
________________________________________________________
Executed in 3.22 millis fish external
usr time 1.13 millis 1.13 millis 0.00 micros
sys time 0.79 millis 0.79 millis 0.00 micros
Setting variables is super fast, and it won't ever make a noticeable impact on startup time:
> time set -g tide_example_var 1
________________________________________________________
Executed in 23.00 micros fish external
usr time 16.00 micros 16.00 micros 0.00 micros
sys time 9.00 micros 9.00 micros 0.00 micros
Follow up to the above: if I put the command in my config.fish or ~/.config/fish/conf.d/tide.fish (which has all of my variables) then I don't get a prompt when the shell starts until I run a command. Has anyone else encountered/fixed this?
This should be essentially implemented on the main branch. If anyone here wants to try it out, that'd be appreciated :)
@IlanCosman I was able to convert my install script to this:
tide configure --auto \
--style='Classic' \
--prompt_colors='16 colors' \
--show_time='No' \
--classic_prompt_separators='Slanted' \
--powerline_prompt_heads='Slanted' \
--powerline_prompt_tails='Slanted' \
--powerline_prompt_height='One line' \
--prompt_spacing='Compact' \
--icons='Few icons'
It works great, thanks so much for implementing this! 😁
Confirming too it works nicely on main!. I really love the addition to tide configure to just print the configuration ❤️.
🚢
Welp, looks like I'm switching from a v5 install to main again! 🤠
(Last time was for the Distrobox right-prompt #332).
Done in v6