fish: confirm before poweroff, reboot, shutdown

This commit is contained in:
Daniel Lundin 2024-10-12 13:24:53 +02:00
parent c07fe99a2e
commit 81e8bca166
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI

View file

@ -16,6 +16,33 @@
]; ];
functions = { functions = {
confirm = {
description = "Ask for confirmation";
argumentNames = [ "message" ];
body = ''
read -l -p 'printf "\\e[31;1m$message\\e[0m (y/N) "' confirm
test "$confirm" = 'y'
'';
};
poweroff = {
description = "Wraps poweroff to first prompt for confirmation";
wraps = "poweroff";
body = ''confirm " Really poweroff $(hostname)?" && command poweroff $argv'';
};
reboot = {
description = "Wraps reboot to first prompt for confirmation";
wraps = "reboot";
body = ''confirm " Really reboot $(hostname)?" && command reboot $argv'';
};
shutdown = {
description = "Wraps shutdown to first prompt for confirmation";
wraps = "shutdown";
body = ''confirm " Really shutdown $(hostname)?" && command shutdown $argv'';
};
tmux-refresh-env = { tmux-refresh-env = {
description = "Refresh environment variables from tmux session"; description = "Refresh environment variables from tmux session";
body = '' body = ''