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

Safe way to print output from callback fn #51

Open
Gautham opened this issue Nov 17, 2020 · 1 comment
Open

Safe way to print output from callback fn #51

Gautham opened this issue Nov 17, 2020 · 1 comment

Comments

@Gautham
Copy link

Gautham commented Nov 17, 2020

First of all, thanks for this library! This awesome 🥇

This is not strictly a zsh-async qn but it might be helpful to others so asking here: What would be the recommended way to display output from the callback fn?

  1. Using normal echo can result in a messy output since the echo output could mess with the current BUFFER making both the output and the command being typed unreadable.
  2. I use powerlevel10k which has a feature called transient prompt. The tl:dr; is that it triggers a zle reset-prompt as a preexec function which basically clears any printed text from the (now-)previous-line prompt.

Do you have any suggestions on how I can safely show my output given the above two constraints?

@Gautham Gautham changed the title Safe way to provide output in callback fn? Safe way to print output from callback fn Nov 17, 2020
@Cyberbeni
Copy link

Generally you want to start async jobs in precmd hooks to get information for prompt segments and then reset-prompt when you get them.
If you want to run scripts manually, you really should just be using regular foreground/background jobs.
Or if you want to have something similar to background jobs but the output is written to files and then you see in one of the prompt segments how many unread outputs you have, I guess that is also doable.

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

No branches or pull requests

2 participants