diff --git a/lib/notfound.zsh b/lib/notfound.zsh new file mode 100644 index 000000000..6a2afb5e9 --- /dev/null +++ b/lib/notfound.zsh @@ -0,0 +1,20 @@ +if [[ -x /usr/bin/pkgfile ]]; then + command_not_found_handler() { + local pkg p + local pid ppid pgrp session tty_nr tpgid + + # double check pkgfile exists + [[ ! -x /usr/bin/pkgfile ]] && return 127 + + # do not run when within a pipe or subshell + [[ ! -t 1 ]] && return 127 + read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat + [[ $$ -eq $tpgid ]] && return 127 + + pkg=$(pkgfile -b -v -- $1) + if [[ -z $pkg ]] && return 127 + + echo "The command \"$1\" can be found in the following packages:" + for p in $pkg; echo " $p" + } +fi diff --git a/lib/theming.zsh b/lib/theming.zsh index b20306a90..2cd4bc603 100644 --- a/lib/theming.zsh +++ b/lib/theming.zsh @@ -7,3 +7,5 @@ random_theme() { themes=($ZSH/themes/*zsh-theme) source "$themes[$RANDOM%$#themes+1]" } + +compdef "_files -g '*.zsh'" set_theme diff --git a/templates/zshrc.arch-zsh-template b/templates/zshrc.arch-zsh-template index 0e5201f13..e94346e8b 100644 --- a/templates/zshrc.arch-zsh-template +++ b/templates/zshrc.arch-zsh-template @@ -29,6 +29,5 @@ load_oh_my_zshell # Load a theme # Look in /usr/local/share/oh-my-zsh/themes/ set_theme "arch-blue" -# random_theme # Customize to your needs...