Reputation: 941
I have some prompt set in oh-my-zsh theme which include some 'curl/wget' commands which obtain weather status. But every time I start the shell, prompt just waiting like 9-10 seconds before welcome me. What I'd like to do is to be able to set 'dynamic' prompt: default prompt without weather shows up momentarily when I start shell, then in 'background' weather is obtained and added to prompt (for example, when some command was executed and another one prompt shown). How can I do that?
UPDATE: I decided to go with cron job which will fetch weather simply every 5 minutes and then I can cat
it not only to zsh prompt, but to any system part I want (for example, to WM statusbar). Although for people who are looking for answer on my exact question I'd recommend to try something like James Andrews proposed.
Upvotes: 0
Views: 450
Reputation: 2123
In your .zshrc
file you could set
# How long to wait before calling TRAPALRM()
TMOUT=300
# called when TMOUT reaches 0
TRAPALRM()
{
# run this command in the background so my shell resets
{
export WEATHER=$(...)
}&!
}
And your prompt could use the $WEATHER
variable.
Upvotes: 2
Reputation: 246837
Couple of ideas:
--max-time
option to limit the damage.Upvotes: 0