mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
added command_not_found_handler
This commit is contained in:
parent
cac408d0b5
commit
7b47c0ce21
@ -75,3 +75,6 @@ bindkey '^e' edit-command-line
|
||||
|
||||
# Load syntax highlighting; should be last.
|
||||
source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null
|
||||
|
||||
# Load command_not_found_handler.
|
||||
source "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/command-not-found.zsh" 2>/dev/null
|
||||
|
||||
21
.config/zsh/command-not-found.zsh
Normal file
21
.config/zsh/command-not-found.zsh
Normal file
@ -0,0 +1,21 @@
|
||||
# This script was borrowed and then customized from the ArchWiki:
|
||||
# https://wiki.archlinux.org/title/Zsh#pacman_-F_"command_not_found"_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}%s${reset} may be found in the following packages:\n" "$1"
|
||||
local pkg
|
||||
for entry in "${entries[@]}"; do
|
||||
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
|
||||
done
|
||||
fi
|
||||
return 127
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user