Activate zsh rehash with pacman hook
This commit is contained in:
parent
0250876649
commit
da9abb7282
4 changed files with 49 additions and 7 deletions
|
@ -21,6 +21,34 @@ _fzf_compgen_path() {
|
|||
_skim_compgen_path
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# search and install packages with skim
|
||||
pi() {
|
||||
SELECTED_PKGS="$(paru -Slq | sk --header='Install packages' -m --preview 'paru -Si {1}')"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue