1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-02-12 05:49:47 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Jasmin
48ccc7b36d
feat(dotnet): update completion script (#12028) 2023-12-06 09:22:06 +01:00
Josh Hubbard
346bd1cd53 feat(frontend-search): add I am lucky option 2023-12-06 09:16:43 +01:00
Josh Hubbard
c37df3ebd4 feat(frontend-search): add nextjs 2023-12-06 09:16:43 +01:00
Marc Cornellà
1ae0515a80
fix(lib): patch omz_urlencode to not encode UTF-8 chars in Termux (#12076)
Fixes #12061
2023-12-06 08:09:45 +01:00
4 changed files with 37 additions and 22 deletions

View File

@ -182,6 +182,8 @@ function omz_urlencode() {
fi fi
# Use LC_CTYPE=C to process text byte-by-byte # Use LC_CTYPE=C to process text byte-by-byte
# Note that this doesn't work in Termux, as it only has UTF-8 locale.
# Characters will be processed as UTF-8, which is fine for URLs.
local i byte ord LC_ALL=C local i byte ord LC_ALL=C
export LC_ALL export LC_ALL
local reserved=';/?:@&=+$,' local reserved=';/?:@&=+$,'
@ -206,6 +208,9 @@ function omz_urlencode() {
else else
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
url_str+="+" url_str+="+"
elif [[ "$PREFIX" = *com.termux* ]]; then
# Termux does not have non-UTF8 locales, so just send the UTF-8 character directly
url_str+="$byte"
else else
ord=$(( [##16] #byte )) ord=$(( [##16] #byte ))
url_str+="%$ord" url_str+="%$ord"

View File

@ -1,22 +1,14 @@
# This scripts is copied from (MIT License): # This scripts is copied from (MIT License):
# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh # https://raw.githubusercontent.com/dotnet/sdk/main/scripts/register-completions.zsh
_dotnet_zsh_complete() #compdef dotnet
{ _dotnet_completion() {
local completions=("$(dotnet complete "$words")") local -a completions=("${(@f)$(dotnet complete "${words}")}")
compadd -a completions
# If the completion list is empty, just continue with filename selection _files
if [ -z "$completions" ]
then
_arguments '*::arguments: _normal'
return
fi
# This is not a variable assignment, don't remove spaces!
_values = "${(ps:\n:)completions}"
} }
compdef _dotnet_zsh_complete dotnet compdef _dotnet_completion dotnet
# Aliases bellow are here for backwards compatibility # Aliases bellow are here for backwards compatibility
# added by Shaun Tabone (https://github.com/xontab) # added by Shaun Tabone (https://github.com/xontab)

View File

@ -60,12 +60,22 @@ Available search contexts are:
| typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` | | typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` |
| unheap | `http://www.unheap.com/?s=` | | unheap | `http://www.unheap.com/?s=` |
| vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` | | vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` |
| nextjs | `https://www.google.com/search?as_sitesearch=nextjs.org&as_q=` |
If you want to have another context, open an Issue and tell us! If you want to have another context, open an Issue and tell us!
## Fallback search behaviour ## Fallback search behaviour
The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced. The plugin will use Google as a fallback if the docs site for a search context does not have a search
function. You can set the fallback search engine to DuckDuckGo by setting
`FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
## DuckDuckGo Lucky Search
Enable DuckDuckGo's "ducky" (lucky) search feature to automatically access the top search result. This feature
is optimized for DuckDuckGo, as Google redirects to an intermediate page. The FRONTEND_SEARCH_FALLBACK_LUCKY
environment variable triggers the use of DuckDuckGo's lucky search, rendering the FRONTEND_SEARCH_FALLBACK
setting unnecessary in this context.
## Author ## Author

View File

@ -27,12 +27,19 @@ alias stackoverflow='frontend stackoverflow'
alias typescript='frontend typescript' alias typescript='frontend typescript'
alias unheap='frontend unheap' alias unheap='frontend unheap'
alias vuejs='frontend vuejs' alias vuejs='frontend vuejs'
alias nextjs='frontend nextjs'
function _frontend_fallback() { function _frontend_fallback() {
case "$FRONTEND_SEARCH_FALLBACK" in if [[ "$FRONTEND_SEARCH_FALLBACK_LUCKY" == "true" ]]; then
duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;; case true in
*) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;; *) echo "https://duckduckgo.com/?q=!ducky+site%3A$1+" ;;
esac esac
else
case "$FRONTEND_SEARCH_FALLBACK" in
duckduckgo) echo "https://duckduckgo.com/?sites=$1&q=" ;;
*) echo "https://google.com/search?as_sitesearch=$1&as_q=" ;;
esac
fi
} }
function frontend() { function frontend() {
@ -70,6 +77,7 @@ function frontend() {
typescript $(_frontend_fallback 'www.typescriptlang.org/docs') typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s=' unheap 'http://www.unheap.com/?s='
vuejs $(_frontend_fallback 'vuejs.org') vuejs $(_frontend_fallback 'vuejs.org')
nextjs $(_frontend_fallback 'nextjs.org')
) )
# show help for command list # show help for command list
@ -81,7 +89,7 @@ function frontend() {
print -P "" print -P ""
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia, nextjs"
print -P "" print -P ""
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
print -P "" print -P ""
@ -96,7 +104,7 @@ function frontend() {
echo "" echo ""
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash," echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia, nextjs"
echo "" echo ""
return 1 return 1
fi fi