A Collection Of Useful BASH Scripts For Heavy Commandline Users
Today, I have stumbled upon a collection of useful BASH scripts for heavy commandline users. These scripts, known as Bash-Snippets, might be quite helpful for those who live in Terminal all day. Want to check the weather of a place where you live? This script will do that for you. Wondering what is the Stock prices? You can run the script that displays the current details of a stock. Feel bored? You can watch some youtube videos. All from commandline. You don’t need to install any heavy memory consumable GUI applications.
Bash-Snippets provides the following 12 useful tools:
- currency – Currency converter.
- stocks – Provides certain Stock details.
- weather – Displays weather details of your place.
- crypt – Encrypt and decrypt files.
- movies – Search and display a movie details.
- taste – Recommendation engine that provides three similar items like the supplied item (The items can be books, music, artists, movies, and games etc).
- short – URL Shortner
- geo – Provides the details of wan, lan, router, dns, mac, and ip.
- cheat – Provides cheat-sheets for various Linux commands.
- ytview – Watch YouTube from Terminal.
- cloudup – A tool to backup your GitHub repositories to bitbucket.
- qrify – Turns the given string into a qr code.
Bash-Snippets – A Collection Of Useful BASH Scripts For Heavy Commandline Users
Installation
You can install these scripts on any OS that supports BASH.
First, clone the GIT repository using command:
Sample output would be:
Go to the cloned directory:
Git checkout to the latest stable release:
Finally, install the Bash-Snippets using command:
This will ask you which scripts to install. Just type Y and press ENTER key to install the respective script. If you don’t want to install a particular script, type N and hit ENTER.
To install all scripts, run:
Sample output would be:
To install a specific script, say currency, run:
Usage
An active Internet connection is required to use these tools. The usage is fairly simple. Let us see how to use all scripts. I assume you have installed all scripts.
1. Currency – Currency Converter
This script converts the currency based on realtime exchange rates. Enter the base currency code and the currency to exchange to, and the amount being exchanged one by one as shown below.
You can also pass all arguments in a single command as shown below.
Refer the following screenshot.
2. Stocks – Display stock price details
If you want to check a stock price details, mention the stock item as shown below.
The above output the Intel stock details.
3. Weather – Display Weather details
Let us check the Weather details by running the following command:
Sample output:
As you see in the above screenshot, it provides the 3 day weather forecast. Without any arguments, it will display the weather details based on your IP address. You can also bring the weather details of a particular city or country like below.
Also, you can view the moon phase by entering the following command:
Sample output would be:
4. Crypt – Encrypt and Decrypt files
This script is a wrapper for openssl that allows you to encrypt and decrypt files quickly and easily.
To encrypt a file, use the following command:
For example, the following command will encrypt a file called ostechnix.txt, and save it as encrypt_ostechnix.txt in the current working directory.
Enter the password for the file twice.
The above command will encrypt the given file using AES 256 level encryption. The password will not be saved in plain text. You can encrypt .pdf, .txt, .docx, .doc, .png, .jpeg type files.
To decrypt the file, use the following command:
Example:
Enter the password to decrypt.
5. Movies – Find Movie details
Using this script, you can find a movie details.
The following command displays the details of a movie called “mother”.
6. Display similar items like the supplied item
To use this script, you need to get the API key here. No worries, it is completely FREE! Once the you got the API, add the following line to your ~/.bash_profile: export TASTE_API_KEY=”yourAPIKeyGoesHere”
Now, you can view the similar item like the supplied item as shown below:
7. Short – Shorten URLs
This script shortens the given URL.
8. Geo – Display the details of your network
This script helps you to find out the details of your network, such as wan, lan, router, dns, mac, and ip geolocation.
For example, to find out your LAN ip, run:
Sample output from my system:
To find your Wan IP:
For more details, just type ‘geo’ in the Terminal.
9. Cheat – Display cheatsheets of Linux commands
Want to refer the cheatsheet of Linux command? Well, it is also possible. The following command will display the cheatsheet of curl command:
Just replace curl with the command of your choice to display its cheatsheet. This can be very useful for the quick reference to any command you want to use.
10. ytview – Watch YouTube videos
Using this script, you can search or watch youtube videos right from the Terminal.
Let us watch some Ed Sheeran videos.
Choose the video you want to play from the list. The selected will play in your default media player.
To view recent videos by an artist, you can use:
To search for videos, just enter:
or just,
11. cloudup – Backup GitHub repositories to bitbucket
Have you hosted any project on GitHub? Great! You can backup the GitHub repositories to bitbucket, a web-based hosting service used for source code and development projects, at any time.
You can either backup all github repositories of the designated user at once with the -a option. Or run it with no flags and backup individual repositories.
To backup GitHub repository, run:
You will be asked to enter your GitHub username, name of the repository to backup, and bitbucket username and password etc.
12. Qrify – Convert Strings into QR code
This script converts any given string of text into a QR code. This is useful for sending links or saving a string of commands to your phone
Sample output would be:
Cool, isn’t it?
Getting help
If you don’t know how to use a particular script, just type that script’s name and press ENTER. You will see the usage details. The following example displays the help section of Qrify script.
Updating scripts
You can update the installed tools at any time suing -u option. The following command updates “weather” tool.
Uninstall
You can uninstall these tools as shown below.
Git clone the repository:
Go to the Bash-Snippets directory:
And uninstall the scripts by running the following command:
Type y and hit ENTER to remove each script.
And, that’s all for now folks. I must admit that I’m very impressed when testing this scripts. I really liked the idea of combing all useful scripts into a single package. Kudos to the developer. Give it a try, you won’t be disappointed.
Cheers!
Resource:
No comments:
Post a Comment