2

I want my zsh prompt to display whether the session has sudo rights (from a previously run sudo command). After looking at the answers to this question, I arranged to use the exit status of sudo -n true to determine whether the sudo timestamp is still valid.

This works as intended, however the command takes ca. 15 ms to complete. Actually all sudo commands seem to have this overhead. This is not much, but I notice it and it bothers me. Given that this is not a computationally expensive operation, is there is a faster way to check this?

  • @JeffSchaller How exactly would that work? – 0x539 Apr 10 at 23:18
  • I've run out of ideas; even if sudo -n true passed, what if you sat at your prompt long enough for the timestamp to run out? That could be minutes or seconds; I don't have a good solution to this problem. – Jeff Schaller Apr 11 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.