Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions extra/command-not-found.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ command_not_found_handler() {
if [[ -n "$pkgs" ]]; then
printf '%s may be found in the following packages:\n' "$cmd"
printf ' %s\n' $pkgs[@]
if [[ -n $PKGFILE_PROMPT_INSTALL_MISSING ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should elide the check here that's done in bash -- invoking this behavior only when pkgfile returns a single result. At best, you offer to install a randomly selected package that might not be what the user wants.

pkg=`echo $pkgs | cut -f1 -d " "`
echo -n "Install $pkg? [Y/n]"
read -r response
[[ -z $response || $response = [Yy] ]] || return 0
printf '\n'
sudo pacman -S --noconfirm -- "$pkg"
return
fi
else
printf 'zsh: command not found: %s\n' "$cmd"
fi 1>&2
Expand Down