Sudo Timeout on MacOS

I’m using homebrew and its casks a lot to install software on my MacBook. This way I’m using a custom script comparable to a simple apt update && apt dist-upgrade on a Linux sysmtem. My update script looks like the following:

#!/bin/zsh
source ./.zshrc

echo "starting local upgrades of homebrew, sdk and nvm\n"

echo "###########################"
echo "# homebrew"
echo "###########################"
# install see https://brew.sh
echo "update installed packages"
brew update
brew upgrade

echo "install packages"
brew install nvm
brew tap buo/cask-upgrade

echo "upgrade casks"
brew cu -ay

brew autoremove
brew cleanup

echo "\n\n\n"
echo "###########################"
echo "# sdk"
echo "###########################"

echo "install sdkman"
# https://sdkman.io/install
#curl -s "https://get.sdkman.io" | bash
sdk selfupdate

echo "update sdkman packages"
sdk update
sdk upgrade

echo "\n\n\n"
echo "###########################"
echo "# nvm"
echo "###########################"
echo "install LTS"
nvm install --lts

echo "\n\n\n"
echo "###########################"
echo "# npm"
echo "###########################"
npm update -g

echo "\n\n\n"
echo "###########################"
echo "done"

Running this keeps most of my system up to date. I only have a few things installed either via AppStore or manually.

But where is the problem and what does this have to do with sudo you ask?

When you have a list of pending updates MacOS will ask you multiple time during a single run of the script for you password because sudo is using a very very short timeout for it. If you want to get rid of that problem run sudo viduso and add the following line after all those Defaults lines you will see in there:

Defaults	timestamp_timeout = -1

This way sudo won’t forget your password in a single session. Of course that -1 could be a problem but for me it isn’t because I always close my terminals when I don’t need them anymore.