├── wiki_0.1-1_all.deb ├── fedora_setup.sh ├── debian_setup.sh ├── mac_setup.sh ├── README.md └── wiki.sh /wiki_0.1-1_all.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaithak/Wiki-bash/HEAD/wiki_0.1-1_all.deb -------------------------------------------------------------------------------- /fedora_setup.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | sudo dnf upgrade 3 | sudo dnf update 4 | sudo dnf install jq 5 | echo -e "\nalias wiki='`pwd`/wiki.sh'" >> ~/.bashrc 6 | source ~/.bashrc 7 | -------------------------------------------------------------------------------- /debian_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get upgrade 4 | sudo apt-get update 5 | sudo apt-get install jq 6 | source ~/.bashrc 7 | echo -e "\nalias wiki='`pwd`/wiki.sh'" >> ~/.bashrc 8 | -------------------------------------------------------------------------------- /mac_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | brew install jq 4 | 5 | SOURCE_FILE=~/.bash_profile 6 | 7 | # check if current shell is 8 | # zsh and change source file 9 | # accordingly 10 | if [ $SHELL == "/bin/zsh" ]; then 11 | SOURCE_FILE=~/.zshrc 12 | fi 13 | echo -e "\nalias wiki='`pwd`/wiki.sh'" >> $SOURCE_FILE 14 | source $SOURCE_FILE 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wiki-bash 2 | A command line tool to access wikipedia 3 | 4 | Steps to run it on debian/MacOS/fedora 5 | 6 | 1) clone or download this repository 7 | 2) `cd` into the directory where you have downloaded or cloned this repo. 8 | 3) run `bash debian_setup.sh` or `bash mac_setup.sh` or `bash fedora_setup.sh` on your terminal depending on your system 9 | 4) Now you're done with the installation process 10 | 5) Run `source ~/.bash_profile` on MacOS and `source ~/.bashrc` on 11 | Linux systems as a Final step. 12 | 13 | Example of using this tool (run the below command in terminal) 14 | 15 | ` 16 | $ wiki "Iron Man" 17 | ` 18 | -------------------------------------------------------------------------------- /wiki.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | search=$1 4 | search=`sed 's/ /%20/g' <<< $search` 5 | inp=`curl -s -H "Accept:application/json" "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&redirects=return&search=$search"` 6 | length=2 7 | 8 | echo -e "Top 2 relevant searches\n" 9 | for i in `seq 0 $((length-1))` 10 | do 11 | output=`jq --argjson i "$i" '.[1][$i]' <<< $inp` 12 | echo -e "\033[0;32m Title: \033[0;36m $output" 13 | output=`jq --argjson i "$i" '.[2][$i]' <<< $inp` 14 | echo -e "\033[0;32m About: \033[0;36m $output" 15 | output=`jq --argjson i "$i" '.[3][$i]' <<< $inp` 16 | echo -e "\033[0;32m Wiki Link: \033[0;36m $output\n" 17 | done 18 | 19 | echo -e "\033[0m" 20 | --------------------------------------------------------------------------------