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

Add configuration to execute processed templates #29

Open
risen opened this issue Apr 16, 2021 · 3 comments
Open

Add configuration to execute processed templates #29

risen opened this issue Apr 16, 2021 · 3 comments
Labels
question Further information is requested

Comments

@risen
Copy link

risen commented Apr 16, 2021

Hi!

Some templates generate a script to be executed. Unless there's a way I don't know of, I'm supposed to use the hook = … entry to:

  • set the executable bit on the generated script
  • execute it
  • maybe clean up afterwards

Maybe there should be an easier way to do it: it could for instance create a tempfile(), execute it, and clean it up, making even the file = … entry optional.

@Misterio77
Copy link
Owner

Misterio77 commented Apr 19, 2021

Hey!

I think this is a little too much of a niche to include a key for. But perhaps you could cut 2/3 of the steps with something like this:

Instead of using rewrite mode, use comments for replacing on your script, something along the lines of:

#!/usr/bin/env bash

some_commands

# Start Flavours
# Your script gets put here
# End Flavours

some_other_commands

Then set it as executable with chmod (flavours won't touch the permissions).

Then just set flavours config.toml to something like:

[[item]]
file = "~/bin/example.sh"
template = "example"
hook = "~/bin/example.sh"

Maybe this will work for you?

@Misterio77 Misterio77 added the question Further information is requested label Apr 19, 2021
@RichardBronosky
Copy link

RichardBronosky commented May 27, 2021

I think this is a little too much of a niche to include a key for.
@Misterio77

Rather than open a new issue, I think this is the best place to address this. Is it possible to get the output of the hook to be shown on the tty where flavours apply is run? To be specific, lets consider https://github.com/chriskempson/base16-shell/blob/master/templates/default.mustache where the template will generate a shell script that, when ran, will output escape/control sequences that your shell should respond to. Running the script via hook will not affect your active shell.

  1. Can this be accomplished with flavours apply?
  2. If not, would you be open to satisfying this niche?

@Misterio77
Copy link
Owner

Misterio77 commented May 22, 2022

@RichardBronosky, my bad for the (very) late reply, my github notifications were all over the place and I'm only now having some time and energy to go back to them.

If you're still interested in the issue you described: Flavours currently does not propagate any output from hooks. We could add a config option for it, yes.

But maybe this tiny program I made could be a better solution for your usecase?

Some quick steps on how to use it with flavours:

  • Add a template compatible with the config (it's very very simple)
  • Add shellcolord $$ & to your shell init file (or shellcolord $fish_pid & if you use fish)
  • Set up flavours to replace colors at .config/shellcolord.conf, with shellcolor apply as hook.
  • Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants