git.iko.soy/typeable/nixpkgs
on master help sign in
command-not-found: add interactive option for auto run
commit0358703df27cdc2526b7c17701a1da79e4e4ad5b authorZenithal <i@zenithal.me> dateSun 16 Jan 2022, 07:53 (5 years ago) parent751d92a
1 file changed+11
nixos/modules/programs/command-not-found/command-not-found.pl+11
nixos/modules/programs/command-not-found/command-not-found.pl+11
@@ -26,6 +26,17 @@ if (!defined $res || scalar @$res == 0) {
2626} elsif (scalar @$res == 1) {
2727 my $package = @$res[0]->{package};
2828 if ($ENV{"NIX_AUTO_RUN"} // "") {
29+ if ($ENV{"NIX_AUTO_RUN_INTERACTIVE"} // "") {
30+ while (1) {
31+ print STDERR "'$program' from package '$package' will be run, confirm? [yn]: ";
32+ chomp(my $comfirm = <STDIN>);
33+ if (lc $comfirm eq "n") {
34+ exit 0;
35+ } elsif (lc $comfirm eq "y") {
36+ last;
37+ }
38+ }
39+ }
2940 exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV));
3041 } else {
3142 print STDERR <<EOF;