forked from deadhead420/arch-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharch-wiki.sh
executable file
·51 lines (47 loc) · 1.45 KB
/
arch-wiki.sh
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
#!/bin/bash
###############################################################
### arch-wiki.sh search arch wiki from the cli
###
### Copyright (C) 2017 Dylan Schacht
###
### By: Dylan Schacht (deadhead)
### Email: deadhead3492@gmail.com
### Webpage: http://arch-anywhere.org
###
### Any questions, comments, or bug reports may be sent to above
### email address. Enjoy, and keep on using Arch.
###
### License: GPL v2.0
###############################################################
if [ "--help" == "$1" ] || [ "-h" == "$1" ]; then
this=${0##*/}
echo
echo "Usage: $this archwiki page name"
echo
echo " where archwiki page name is title of page on wiki.archlinux.org"
echo
echo "Examples:"
echo " $this ssh"
echo " $this installation guide"
echo " $this the arch way"
echo
exit 0
fi
if [ -n "$BROWSER" ]; then run_browser=$BROWSER
else BROWSER=lynx int=1
until [ -n "$run_browser" ]
do
if (which $BROWSER &>/dev/null); then run_browser=$BROWSER
elif [ "$int" -eq "1" ]; then BROWSER=elinks
elif [ "$int" -eq "2" ]; then BROWSER=links
else
echo "Please install one of the following packages to use this script: elinks links lynx"
exit 1
fi
int=$((int+1))
done
fi
query="$*" # get all params into single query string
query=${query// /_} # substitute spaces with underscores in the query string
# load ArchWiki page with automatic redirect to the correct URL:
exec "$run_browser" "https://wiki.archlinux.org/index.php/Special:Search/${query}"