-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmsearch
executable file
·76 lines (71 loc) · 3.53 KB
/
dmsearch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
#
# Script name: dmsearch
# Description: Search various search engines (inspired by surfraw).
# Dependencies: dmenu and a web browser
# GitLab: https://www.gitlab.com/dwt1/dmscripts
# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE
# Contributors: Derek Taylor
# Ali Furkan Yıldız
# Defining our web browser.
DMBROWSER="qutebrowser"
# An array of search engines. You can edit this list to add/remove
# search engines. The format must be: "engine_name - url".
# The url format must allow for the search keywords at the end of the url.
# For example: https://www.amazon.com/s?k=XXXX searches Amazon for 'XXXX'.
declare -a options=(
"amazon https://www.amazon.com/s?k="
"finn.no https://www.finn.no/globalsearchlander?q="
"komplett.no https://www.komplett.no/search?q="
"Prisjakt.no https://www.prisjakt.no/search?search="
"archaur https://aur.archlinux.org/packages/?O=0&K="
"archpkg https://archlinux.org/packages/?sort=&q="
"archwiki https://wiki.archlinux.org/index.php?search="
"arxiv https://arxiv.org/search/?searchtype=all&source=header&query="
"bbcnews https://www.bbc.co.uk/search?q="
"bing https://www.bing.com/search?q="
"cliki https://www.cliki.net/site/search?query="
"cnn https://www.cnn.com/search?q="
"coinbase https://www.coinbase.com/price?query="
"debianpkg https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords="
"discogs https://www.discogs.com/search/?&type=all&q="
"duckduckgo https://duckduckgo.com/?q="
"ebay https://www.ebay.com/sch/i.html?&_nkw="
"github https://github.com/search?q="
"gitlab https://gitlab.com/search?search="
"google https://www.google.com/search?q="
"googleimages https://www.google.com/search?hl=en&tbm=isch&q="
"googlenews https://news.google.com/search?q="
"imdb https://www.imdb.com/find?q="
"lbry https://lbry.tv/$/search?q="
"odysee https://odysee.com/$/search?q="
"reddit https://www.reddit.com/search/?q="
"slashdot https://slashdot.org/index2.pl?fhfilter="
"socialblade https://socialblade.com/youtube/user/"
"sourceforge https://sourceforge.net/directory/?q="
"stack https://stackoverflow.com/search?q="
"startpage https://www.startpage.com/do/dsearch?query="
"stockquote https://finance.yahoo.com/quote/"
"thesaurus https://www.thesaurus.com/misspelling?term="
"translate https://translate.google.com/?sl=auto&tl=en&text="
"urban https://www.urbandictionary.com/define.php?term="
"wayback https://web.archive.org/web/*/"
"webster https://www.merriam-webster.com/dictionary/"
"wikipedia https://en.wikipedia.org/wiki/"
"wiktionary https://en.wiktionary.org/wiki/"
"wolfram https://www.wolframalpha.com/input/?i="
"youtube https://www.youtube.com/results?search_query="
"quit"
)
# Picking a search engine.
while [ -z "$engine" ]; do
enginelist=$(printf '%s\n' "${options[@]}" | dmenu -i -l 20 -p 'Choose search engine:') || exit
engineurl=$(echo "$enginelist" | awk '{print $NF}')
engine=$(echo "$enginelist" | awk '{print $1}')
done
# Searching the chosen engine.
while [ -z "$query" ]; do
query=$(echo "$engine" | dmenu -p 'Enter search query:') || exit
done
# Display search results in web browser
$DMBROWSER "$engineurl""$query"