FWDekker / mommy

mommy's here to support you, in any shell, on any system~ ❤️
The Unlicense
197 stars 5 forks source link

add option to start an interactive mommy session #46

Open dsprenkels opened 1 year ago

dsprenkels commented 1 year ago

It is usually desireable for mommy to be disabled by default, but sometimes you might like to enable it for a single session. In these cases it might be nice to have a mommy [-i | --interactive] that starts a new shell with mommy enabled internally. The user should be able to exit that shell in the regular way, i.e., with exit.

FWDekker commented 1 year ago

woah, awesome idea!

when you say "enabled", do you mean "act as if every command is prefixed by mommy"? because the way I have integrated mommy in my shell is the way it's explained in the fish section, which is different than passing each command through mommy.

an alternative would be to add the option mommy --gated (weird name, need a better one) which checks MOMMY_INTERACTIVE: if it is set and non-zero, mommy behaves as it does currently, but if not set or zero, it runs the command normally but without outputting anything. this way, you can just follow the integration steps in the shell integration section, but also add the --gated option so that mommy isn't actually enabled until you set MOMMY_INTERACTIVE=1 in your shell. which is kind of like running mommy -i, I guess. (unfortunately it is impossible to make mommy -i or any other command set the environment variable.)

i would also like a mommy -i command as you proposed, but I'm not sure it's feasible because I don't know a generic way for shells to always pass every command through mommy. you could maybe create some sort of shell wrapper so that after mommy -i each command you give the interactive session is passed to the shell of your choice, but then you cannot use environment variables :/ last option would be to create our own shell, but i really think that's out of scope for mommy.

maybe you have other solutions in mind?

FWDekker commented 8 months ago

ok, if you had to choose, would you rather:

  1. write mommy -t to toggle whether mommy is enabled in all shells by the current user, or
  2. write export MOMMY_ENABLED=0 or export MOMMY_ENABLED=1 to disable/enable mommy only in the current shell?

the former is much shorter, easier to remember, and easier to write, but there's no way to restrict the behaviour only to the current shell, so the state will be stored in a file, and apply to all shells by the current user. (i can also add mommy -t 0 and mommy -t 1 to not toggle but explicitly disable/enable.)

the latter is harder to use and just generally less nice, but will apply only to the current shell (and sub-shells).