From 0358703df27cdc2526b7c17701a1da79e4e4ad5b Mon Sep 17 00:00:00 2001 From: Zenithal Date: Sun, 16 Jan 2022 07:53:54 +0800 Subject: command-not-found: add interactive option for auto run --- nixos/modules/programs/command-not-found/command-not-found.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'nixos') diff --git a/nixos/modules/programs/command-not-found/command-not-found.pl b/nixos/modules/programs/command-not-found/command-not-found.pl index 220d057b7f4f..af2c606230f4 100644 --- a/nixos/modules/programs/command-not-found/command-not-found.pl +++ b/nixos/modules/programs/command-not-found/command-not-found.pl @@ -26,6 +26,17 @@ if (!defined $res || scalar @$res == 0) { } elsif (scalar @$res == 1) { my $package = @$res[0]->{package}; if ($ENV{"NIX_AUTO_RUN"} // "") { + if ($ENV{"NIX_AUTO_RUN_INTERACTIVE"} // "") { + while (1) { + print STDERR "'$program' from package '$package' will be run, confirm? [yn]: "; + chomp(my $comfirm = ); + if (lc $comfirm eq "n") { + exit 0; + } elsif (lc $comfirm eq "y") { + last; + } + } + } exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV)); } else { print STDERR <