Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
60442dc4
Commit
60442dc4
authored
Jun 10, 2020
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web-search: allow custom search engines
parent
3c777ebf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
README.md
plugins/web-search/README.md
+24
-0
web-search.plugin.zsh
plugins/web-search/web-search.plugin.zsh
+12
-1
No files found.
plugins/web-search/README.md
View file @
60442dc4
...
...
@@ -52,3 +52,27 @@ Also there are aliases for bang-searching DuckDuckGo:
|
`map`
|
`!m`
|
|
`image`
|
`!i`
|
|
`ducky`
|
`!`
|
### Custom search engines
If you want to add other search contexts to the plugin, you can use the
`$ZSH_WEB_SEARCH_ENGINES`
variable. Set it before Oh My Zsh is sourced,
with the following format:
```
zsh
ZSH_WEB_SEARCH_ENGINES
=(
<context> <URL>
<context> <URL>
)
```
where
`<context>`
is the name of the search context, and
`<URL>`
a URL of
the same type as the search contexts above. For example, to add
`reddit`
,
you'd do:
```
zsh
ZSH_WEB_SEARCH_ENGINES
=(
reddit
"https://www.reddit.com/search/?q="
)
```
These custom search engines will also be turned to aliases, so you can
both do
`web_search reddit <query>`
or
`reddit <query>`
.
plugins/web-search/web-search.plugin.zsh
View file @
60442dc4
...
...
@@ -6,6 +6,7 @@ function web_search() {
# define search engine URLS
typeset
-A
urls
urls
=(
$ZSH_WEB_SEARCH_ENGINES
google
"https://www.google.com/search?q="
bing
"https://www.bing.com/search?q="
yahoo
"https://search.yahoo.com/search?p="
...
...
@@ -25,7 +26,7 @@ function web_search() {
# check whether the search engine is supported
if
[[
-z
"
$urls
[
$1
]"
]]
;
then
echo
"Search engine
$1
not supported."
echo
"Search engine
'
$1
'
not supported."
return
1
fi
...
...
@@ -67,3 +68,13 @@ alias youtube='web_search duckduckgo \!yt'
alias
map
=
'web_search duckduckgo \!m'
alias
image
=
'web_search duckduckgo \!i'
alias
ducky
=
'web_search duckduckgo \!'
# other search engine aliases
if
[[
${#
ZSH_WEB_SEARCH_ENGINES
}
-gt
0
]]
;
then
typeset
-A
engines
engines
=(
$ZSH_WEB_SEARCH_ENGINES
)
for
key
in
${
(k)engines
}
;
do
alias
"
$key
"
=
"web_search
$key
"
done
unset
engines key
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment