From 7c548e23e29ed02e278001f36fbcaa8a34807d8e Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Sun, 4 Feb 2024 12:49:24 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Ask=20for=20sudo=20in=20dot.fish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/dot.fish | 4 ++++ script/utils.fish | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/script/dot.fish b/script/dot.fish index 031fbda..bde325e 100755 --- a/script/dot.fish +++ b/script/dot.fish @@ -145,6 +145,10 @@ end # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ask_for_sudo + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # Ensure npm is available. "$DOT/node/volta.fish" diff --git a/script/utils.fish b/script/utils.fish index b857568..d9ae1da 100755 --- a/script/utils.fish +++ b/script/utils.fish @@ -156,3 +156,19 @@ end function cmd_exists -a cmd command -v "$cmd" &>/dev/null end + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +function ask_for_sudo + sudo -v &>/dev/null + + # Update existing 'sudo' timestamp until this script has finished. + # + # https://gist.github.com/cowboy/3118588 + + while true + sudo -n true + sleep 60 + kill -0 "$fish_pid" || exit + end &>/dev/null & +end