MichaelAquilina / zsh-auto-notify

⏰ ZSH plugin that automatically sends out a notification when a long running task has completed.
GNU General Public License v3.0
415 stars 43 forks source link

Change output to minutes and seconds ? #48

Open aindriu80 opened 1 year ago

aindriu80 commented 1 year ago

Very nice plugin

Can you change the default behaviour that reports in seconds to minutes and seconds?

MichaelAquilina commented 1 year ago

Thanks :)

Unless there is an easy way to convert this via a very standard command line utility, its unlikely I'll implement this in bash as it would be quite cumbersome.

If you or someone in the community is aware of an easy way to do that, then I'm happy to accept a PR or just a recommendation for me to look into!

arvyanh commented 9 months ago

If we don't care about hours, I think something like echo $((155/60)) $((155%60)) should be enough. (155 is the seconds)

qin-ziliang commented 4 months ago

I am not familiar with shell language, but through the @arvyanh reminder, I changed the function _auto_notify_message() and simply realized the function of displaying hours and minutes.

function _auto_notify_message() {
    local command="$1"
    local elapsed="$(($2/3600))h $((($2%3600)/60))m $(($2%60))s ⏳️"
    local exit_code="$3"
    local platform="$(uname)"
    # Run using echo -e in order to make sure notify-send picks up new line
    local DEFAULT_TITLE="\"%command\" Completed ✅"
    local DEFAULT_BODY="$(echo -e "Total time: %elapsed\nExit code: %exit_code ♻️")"