From 33037ba06d77243033a50a157c494578dd1b11f6 Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Wed, 17 Aug 2022 21:57:49 +0300 Subject: [PATCH] Use pkgfile command not found handler for arch --- home/.config/zsh/01-env.zsh | 5 +++++ home/.config/zsh/03-aliases.zsh | 31 +------------------------------ 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/home/.config/zsh/01-env.zsh b/home/.config/zsh/01-env.zsh index b85aece..18aa0e2 100644 --- a/home/.config/zsh/01-env.zsh +++ b/home/.config/zsh/01-env.zsh @@ -73,3 +73,8 @@ fi # Disable dotdrop submodule auto update export DOTDROP_AUTOUPDATE=no + +{%@@ if os == "arch" @@%} +# Enable pkgfile command not found handler +source /usr/share/doc/pkgfile/command-not-found.zsh +{%@@ endif @@%} diff --git a/home/.config/zsh/03-aliases.zsh b/home/.config/zsh/03-aliases.zsh index defd5de..846323f 100644 --- a/home/.config/zsh/03-aliases.zsh +++ b/home/.config/zsh/03-aliases.zsh @@ -12,35 +12,7 @@ forgit_revert_commit=fgrc # Modern replacement for ls alias ls='exa' -{%@@ if os == "arch" @@%} -# Command not found handler -# source https://wiki.archlinux.org/title/Zsh#pacman_-F_%22command_not_found%22_handler -function command_not_found_handler { - local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m' - printf 'zsh: command not found: %s\n' "$1" - local entries=( - ${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"} - ) - if (( ${#entries[@]} )) - then - printf "${bright}$1${reset} may be found in the following packages:\n" - local pkg - for entry in "${entries[@]}" - do - # (repo package version file) - local fields=( - ${(0)entry} - ) - if [[ "$pkg" != "${fields[2]}" ]] - then - printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}" - fi - printf ' /%s\n' "${fields[4]}" - pkg="${fields[2]}" - done - fi -} -{%@@ elif os == "termux" @@%} +{%@@ if os == "termux" @@%} function command_not_found_handler { printf 'zsh: command not found: %s\n' "$1" $PREFIX/libexec/termux/command-not-found $1 @@ -64,7 +36,6 @@ pr() { paru -Rns $(echo $SELECTED_PKGS) fi } -{%@@ endif @@%} # find and open man pages with fzf fman() {