Adding the following line to your .zshrc will refresh it immediately after installing something from pacman or yaourt.
TRAPUSR1() { rehash}; precmd() { [[ $history[$[ HISTCMD -1 ]] == *(pacman|yaourt)* ]] && killall -USR1 zsh }
The above code will also refresh for other terminals that are already open, so no need to close it or rehash it.
if you are using Debian or other, just change *(pacman|yaourt)* to your package manager, e.g: *(apt-get|aptitude)* or just one package manger: *apt-get*
Nice one :)
ReplyDeleteI use "add-zsh-hook precmd rehash_precmd" to avoid a potential conflict with an already defined precmd.
This comment has been removed by the author.
ReplyDeleteUnfortunately, you have to install a signal handler for USR1 into every ZSH process (e.g. trap USR1 in your /etc/zshenv) otherwise all zsh processes, including scripts, who don't trap USR1 will exit.
ReplyDeleteMy zshrc uses a different approach that should work everywhere: https://github.com/eatnumber1/dotfiles/commit/1237e2f880758dc9e819048f51a505a11698a5ce