Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/victoriamcn/cli-weather
The command line isn’t just for interfacing with your device - you can write whole applications that only run in your terminal! For this exercise, you should write a simple shell script that gets the weather for a particular zip code.
https://github.com/victoriamcn/cli-weather
cli-app shell-script
Last synced: about 1 month ago
JSON representation
The command line isn’t just for interfacing with your device - you can write whole applications that only run in your terminal! For this exercise, you should write a simple shell script that gets the weather for a particular zip code.
- Host: GitHub
- URL: https://github.com/victoriamcn/cli-weather
- Owner: victoriamcn
- License: mit
- Created: 2024-01-29T22:24:42.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-30T04:55:41.000Z (about 1 year ago)
- Last Synced: 2024-11-16T19:25:41.438Z (3 months ago)
- Topics: cli-app, shell-script
- Language: Shell
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CLI Weather App
## Description
Simple shell script that gets the weather for a particular zip code.
## Table of Contents
- [Installation and Usage](#installation-and-usage)
- [Demo]()
- [License](#license)
- [Credits](#credits)
- [Badges](#badges)
-## License
[](https://github.com/victoriamcn/CLI-Weather/blob/main/LICENSE)
## Installation and Usage
*Note: This app works for US Zip Codes only*
1. **Clone this repository to your local computer.**
2. **Open the repository and the terminal within your preferred `IDE/Editor`.**
Examples: `VSCode`, `Notepad`, `Atom`, `Brackets`, `Eclipse`
3. **Install Dependencies**
Type `npm i` in the open terminal's command line.
Install [`./jq`](https://jqlang.github.io/jq/) on your device.
4. **API Key Set Up**
- Register with [`tomorrow.io`](https://app.tomorrow.io/signin?_gl=1*dxtskt*_ga*MTkxNDc5Mzk2LjE3MDY1NzY4NTY.*_ga_FYZPGBJRTX*MTcwNjU4MjkzNC4yLjEuMTcwNjU4Mjk0Mi4wLjAuMA..&return_to=%2Fdevelopment%2Fkeys) to get your private `API key.`
- Create a `.env` file with the following variable:
```
TOMORROW_IO_API_KEY = 'YOUR_KEY_HERE'
```
5. **Make the Script Executable**
Type the following in the open terminal to make the script executable within the current repository:
```
chmod +x generate_weather.sh
```
Command Breakdown:
- `chmod`: This command stands for "change mode," and it is used to change the permissions of a file.
- `+x`: In Unix-like operating systems, the execute permission is represented by the letter `x`. Adding the `+x`option means granting the execute permission.
- `generate_weather.sh`: This is the name of the file for which you want to change the permissions. In this case, it's assumed to be a shell script (`.sh`) file named `generate_weather`.6. **Execute the Script**
Execute the script directly from the command line with
```
./generate_weather.sh --zipcode 29601```
---
### ***OPTIONAL SET-UP***
7. **Make Custom Shell Script Accessible from Any Location**
Move the script to a directory in your system's `PATH`:
```
sudo mv generate_weather.sh /usr/local/bin/generate_weather
```
- This assumes that `/usr/local/bin`` is in your PATH. You can adjust the destination based on your preference.
- Skip Step 6 if you start getting a headache.
8. **Create an Alias for Custom Shell Script**
- Open your shell configuration file in a text editor. (e.g., `~/.bashrc` for Bash, `~/.zshrc` for Zsh)
- Add the following line at the end of the file:
```
alias weather="/path/to/your/generate_weather.sh"
```
- If you did `Step 6` and moved the script to a directory in your PATH, you can simply use the script name and then save the file.
```
alias weather="generate_weather"
```
- After making changes to your shell configuration file, you need to either restart your terminal or run the following command to apply the changes:
```
source ~/.bashrc # For Bash
```
```
source ~/.zshrc # For Zsh
```
- Test the Alias by typing the following in the terminal:
```
weather --zipcode 29601
```## Credits
### [Weather API by tomorrow.io](https://www.tomorrow.io/a/faq/weather-api/can-i-get-weather-data-by-zip-code-using-an-api/)
### [dotenv-cli](https://www.npmjs.com/package/dotenv-cli)
### [jq](https://jqlang.github.io/jq/)
### [DataCamp Tutorial: How to Write Bash Script](https://www.datacamp.com/tutorial/how-to-write-bash-script-tutorial)
### [The Shell Scripting Tutorial](https://www.shellscript.sh/)
## Badges
[](https://git-scm.com/)
[](https://docs.github.com/en/get-started/quickstart/hello-world)
[](https://www.npmjs.com/)
[]((https://www.shellscript.sh/))
[](https://code.visualstudio.com/)