From f6f2de9b6ce51ee557c2168599cdca671a4dde9c Mon Sep 17 00:00:00 2001 From: xusd320 Date: Thu, 7 Aug 2025 14:46:00 +0800 Subject: [PATCH] feat(web-search): add crates.io, docs.rs (#13250) --- plugins/direnv/README.md | 4 ++-- plugins/direnv/direnv.plugin.zsh | 16 ++++------------ plugins/web-search/web-search.plugin.zsh | 4 ++++ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/plugins/direnv/README.md b/plugins/direnv/README.md index 8deaf38bb..602066dfa 100644 --- a/plugins/direnv/README.md +++ b/plugins/direnv/README.md @@ -1,6 +1,6 @@ # direnv plugin -This plugin creates the [Direnv](https://direnv.net/) hook. +This plugin initializes the [Direnv](https://direnv.net/) shell hook for zsh. To use it, add `direnv` to the plugins array in your zshrc file: @@ -10,6 +10,6 @@ plugins=(... direnv) ## Requirements -In order to make this work, you will need to have the direnv installed. +In order to make this work, you will need to have direnv installed and available in your PATH. More info on the usage and install: https://github.com/direnv/direnv diff --git a/plugins/direnv/direnv.plugin.zsh b/plugins/direnv/direnv.plugin.zsh index c026dbe76..0515a7e2f 100644 --- a/plugins/direnv/direnv.plugin.zsh +++ b/plugins/direnv/direnv.plugin.zsh @@ -4,16 +4,8 @@ if (( ! $+commands[direnv] )); then return fi -_direnv_hook() { - trap -- '' SIGINT; - eval "$(direnv export zsh)"; - trap - SIGINT; -} -typeset -ag precmd_functions; -if [[ -z "${precmd_functions[(r)_direnv_hook]+1}" ]]; then - precmd_functions=( _direnv_hook ${precmd_functions[@]} ) -fi -typeset -ag chpwd_functions; -if [[ -z "${chpwd_functions[(r)_direnv_hook]+1}" ]]; then - chpwd_functions=( _direnv_hook ${chpwd_functions[@]} ) +# Load direnv's shell hook, which is the supported integration mechanism for +# modern direnv versions. +if ! eval "$(direnv hook zsh)"; then + echo "Warning: direnv hook failed to initialize. Please ensure direnv is installed correctly." fi diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 98826ef72..93237f4e2 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -37,6 +37,8 @@ function web_search() { claudeai "https://claude.ai/new?q=" reddit "https://www.reddit.com/search/?q=" ppai "https://www.perplexity.ai/search/new?q=" + rscrate "https://crates.io/search?q=" + rsdoc "https://docs.rs/releases/search?query=" ) # check whether the search engine is supported @@ -95,6 +97,8 @@ alias grok='web_search grok' alias claudeai='web_search claudeai' alias reddit='web_search reddit' alias ppai='web_search ppai' +alias rscrate='web_search rscrate' +alias rsdoc='web_search rsdoc' #add your own !bang searches here alias wiki='web_search duckduckgo \!w'