-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_aliases
418 lines (377 loc) · 12 KB
/
.bash_aliases
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
search() {
first=$1
search=""
shift
for term in $@; do
search="$search%20$term"
done
case "$first" in
"-g")
google $@
;;
"-yh")
yahoo $@
;;
"-duk")
duckduckgo $@
;;
"-bng")
bing $@
;;
"-wik")
wikipedia $@
;;
"-ytb")
youtube $@
;;
"-vim")
echo "Searching on Vimeo: $@"
xdg-open "https://vimeo.com/search?q=$search"
;;
"-img")
engine=$(<~/.search/.defaultImgSearchEngine.txt)
$engine $@
;;
"-vid")
engine=$(<~/.search/.defaultVidSearchEngine.txt)
$engine $@
;;
"-default")
echo "Default Search Engine: "
cat ~/.search/.defaultSearchEngine.txt
echo "Default Search Engine for Image: "
cat ~/.search/.defaultImgSearchEngine.txt
echo "Default Search Engine for Video: "
cat ~/.search/.defaultVidSearchEngine.txt
;;
"-setdefault")
set_default
;;
"--help" | "")
echo "To search on the internet. Just opens a browser."
echo " SYNTAX : search [-option] [-suboption] search_string"
echo ""
echo " search search_string "
echo " Will search search_string on default search engine"
echo ""
echo "Available options:"
echo " -g: "
echo " searches on google"
echo " Available Sub Options:"
echo " -i: "
echo " searches on google images"
echo " -n: "
echo " searches on google news"
echo " -v: "
echo " searches on google videos"
echo " -m: "
echo " searches on google maps"
echo " -duk: "
echo " searches on DuckDuckGo"
echo " -i: "
echo " searches on DuckDuckGo images"
echo " -n: "
echo " searches on DuckDuckGo news"
echo " -v: "
echo " searches on DuckDuckGo videos"
echo " -m: "
echo " searches on DuckDuckGo maps"
echo " -yh: "
echo " searches on yahoo"
echo " -bng: "
echo " searches on bing"
echo " Available Sub Options:"
echo " -i: "
echo " searches on bing images"
echo " -n: "
echo " searches on bing news"
echo " -v: "
echo " searches on bing videos"
echo " -m: "
echo " searches on bing maps"
echo " -wik: "
echo " searches on wikipedia"
echo " -ytb: "
echo " searches on youtube"
echo " -vim: "
echo " searches on vimeo"
echo " -img: "
echo " searches on default image search engine"
echo " -vid: "
echo " searches on default video search engine"
echo " -default: "
echo " shows default search engines"
echo " -setdefault: "
echo " set default search engines"
;;
*)
engine=$(<~/.search/.defaultSearchEngine.txt)
$engine $first $@
esac
}
search_init(){
mkdir ~/.search
touch ~/.search/.defaultSearchEngine.txt
touch ~/.search/.defaultVidSearchEngine.txt
touch ~/.search/.defaultImgSearchEngine.txt
echo "google" > ~/.search/.defaultSearchEngine.txt
echo "google -i" > ~/.search/.defaultImgSearchEngine.txt
echo "youtube" > ~/.search/.defaultVidSearchEngine.txt
}
set_default(){
echo "Change default search engine? ( y / n )"
read input
# ["$input" = "y" | "$input" = "Y"] && \
# echo "ok"
# if [ "$input" == "y" "$input" = "Y" ] \
# echo "ok"
if [ "$input" == "y" ] || [ "$input" == "Y" ] ; then
echo "1) Change default search engine"
echo "2) Change default search engine for image"
echo "3) Change default search engine for video"
read input
if [ "$input" -eq 1 ] ; then
echo "Change default search engine to:"
echo " 1) Google"
echo " 2) DuckDuckGo"
echo " 3) Yahoo"
echo " 4) Bing"
read input
if [ "$input" -eq 1 ] ; then
echo "google" > ~/.search/.defaultSearchEngine.txt
elif [ "$input" -eq 2 ]; then
echo "duckduckgo" > ~/.search/.defaultSearchEngine.txt
elif [ "$input" -eq 3 ]; then
echo "yahoo" > ~/.search/.defaultSearchEngine.txt
elif [ "$input" -eq 4 ]; then
echo "bing" > ~/.search/.defaultSearchEngine.txt
else
echo "Wrong choice"
fi
elif [ "$input" -eq 2 ]; then
echo "Change default search engine for image to:"
echo " 1) Google"
echo " 2) Bing"
echo " 3) DuckDuckGo"
read input
if [ "$input" -eq 1 ] ; then
echo "google -i" > ~/.search/.defaultImgSearchEngine.txt
elif [ "$input" -eq 2 ]; then
echo "bing -i" > ~/.search/.defaultImgSearchEngine.txt
elif [ "$input" -eq 3 ]; then
echo "duckduckgo -i" > ~/.search/.defaultImgSearchEngine.txt
fi
elif [ "$input" -eq 3 ]; then
echo "Change default search engine for video to:"
echo " 1) Youtube"
echo " 2) Google"
echo " 3) Bing"
echo " 4) DuckDuckGo"
read input
if [ "$input" -eq 1 ] ; then
echo "youtube" > ~/.search/.defaultVidSearchEngine.txt
elif [ "$input" -eq 2 ] ; then
echo "google -v" > ~/.search/.defaultVidSearchEngine.txt
elif [ "$input" -eq 3 ] ; then
echo "bing -v" > ~/.search/.defaultVidSearchEngine.txt
elif [ "$input" -eq 4 ] ; then
echo "duckduckgo -v" > ~/.search/.defaultVidSearchEngine.txt
fi
fi
fi
}
bing() {
first=$1
search=""
case $first in
"-i")
shift
for term in $@; do
search="$search%20$term"
done
echo "Bing Image search for: $@"
xdg-open "https://www.bing.com/images/search?q=$search"
;;
"-v")
shift
for term in $@; do
search="$search%20$term"
done
echo "Bing Video search for: $@"
xdg-open "https://www.bing.com/videos/search?q=$search"
;;
"-n")
shift
for term in $@; do
search="$search%20$term"
done
echo "Bing News search for: $@"
xdg-open "https://www.bing.com/news/search?q=$search"
;;
"-m")
shift
for term in $@; do
search="$search%20$term"
done
echo "Bing Maps search for: $@"
xdg-open "https://www.bing.com/maps?q=$search"
;;
*)
echo "Searching on bing : $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "https://www.bing.com/search?q=$search"
esac
}
yahoo() {
first=$1
search=""
case $first in
"-i")
shift
for term in $@; do
search="$search%20$term"
done
echo "Yahoo Image search for: $@"
xdg-open "https://images.search.yahoo.com/search/images?p=$search"
;;
"-v")
shift
for term in $@; do
search="$search%20$term"
done
echo "Yahoo Video search for: $@"
xdg-open "https://video.search.yahoo.com/search/video?p=$search"
;;
"-n")
shift
for term in $@; do
search="$search%20$term"
done
echo "Yahoo News search for: $@"
xdg-open "https://news.search.yahoo.com/search/news?p=$search"
;;
"-a")
shift
for term in $@; do
search="$search%20$term"
done
echo "Yahoo Answers search for: $@"
xdg-open "https://answers.search.yahoo.com/search/answers?p=$search"
;;
*)
echo "Searching on Yahoo: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "https://search.yahoo.com/search?p=$search"
esac
}
duckduckgo() {
first=$1
search=""
case $first in
"-i")
shift
for term in $@; do
search="$search%20$term"
done
echo "DuckDuckGo Image search for: $@"
xdg-open "https://duckduckgo.com/?q=$search&iax=images&ia=images"
;;
"-v")
shift
for term in $@; do
search="$search%20$term"
done
echo "DuckDuckGo Video search for: $@"
xdg-open "https://duckduckgo.com/?q=$search&iax=videos&ia=videos"
;;
"-n")
shift
for term in $@; do
search="$search%20$term"
done
echo "DuckDuckGo News search for: $@"
xdg-open "https://duckduckgo.com/?q=$search&iar=news&ia=news"
;;
"-m")
shift
for term in $@; do
search="$search%20$term"
done
echo "DuckDuckGo Maps search for: $@"
xdg-open "https://duckduckgo.com/?q=$search&iaxm=maps"
;;
*)
echo "Searching on DuckDuckGo: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "https://duckduckgo.com/?q=$search"
esac
}
google() {
first=$1
search=""
case $first in
"-i")
shift
for term in $@; do
search="$search%20$term"
done
echo "Google Image search for: $@"
xdg-open "http://www.google.com/search?q=$search&tbm=isch&"
;;
"-v")
shift
for term in $@; do
search="$search%20$term"
done
echo "Google Video search for: $@"
xdg-open "http://www.google.com/search?q=$search&tbm=vid"
;;
"-n")
shift
for term in $@; do
search="$search%20$term"
done
echo "Google News search for: $@"
xdg-open "http://www.google.com/search?q=$search&tbm=nws"
;;
"-m")
shift
for term in $@; do
search="$search%20$term"
done
echo "Google Maps search for: $@"
xdg-open "https://www.google.com/maps/search/$search/"
;;
*)
echo "Googling: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "http://www.google.com/search?q=$search"
esac
}
youtube() {
search=""
echo "Searching on Youtube: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "https://www.youtube.com/results?search_query=$search"
}
wikipedia() {
search=""
echo "Searching on Wikipedia: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "https://en.wikipedia.org/w/index.php?search=$search"
}
open() {
xdg-open "$@"
}