https://github.com/qjack001/bash-template
A template for creating simple command-line-interfaces.
https://github.com/qjack001/bash-template
bash cli command-line template
Last synced: 2 months ago
JSON representation
A template for creating simple command-line-interfaces.
- Host: GitHub
- URL: https://github.com/qjack001/bash-template
- Owner: qjack001
- License: mit
- Created: 2021-04-27T00:50:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-27T02:17:15.000Z (about 5 years ago)
- Last Synced: 2025-03-24T09:12:45.592Z (over 1 year ago)
- Topics: bash, cli, command-line, template
- Language: Shell
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[ [How to use](#how-to-use) ][ [Installing your CLI](#installing-your-cli) ][ [Contributing](#contributing) ][ [Attribution](#attribution) ][ [Examples](#examples) ]
A template file for creating simple command-line-interfaces. Includes commonly needed functions, such as coloring text and getting input, as well as hard-to-implement features, like a keyboard-navigatable menu.
### How to use
To get started, clone this repo (or hit the Use this template button) and open the [`template.sh`](template.sh) file in a text editor. Fill-in your CLI's information (marked by ``), and add your functions to the file — see the default [`no_args`](template.sh#L45) function for an example of the "library" in-use. Add your function to [`handel_input`](template.sh#L14)'s list of commands, and test it out:
```bash
sh template.sh
```
Rename the template file to `.sh` and push your changes to Github (or any other git host). Find the URL to the raw copy of the script and replace `source_url` with it. Push the changes again, and then try fetching it by running:
```bash
sh .sh update
```
When it prompts you to install the script, choose "no" for now. **Important:** make sure you've commited all your changes before running the `update` command, as it will overwrite your `.sh` file (if you are in your repo's directory).
### Installing your CLI
To install it globally (currently moves it to `/usr/local/bin/`), run:
```bash
sh .sh install
```
**Important:** make sure you have commited all your changes before running the `install` command, as it will _move_ the script not copy (thus re-moving it from your repo).
Alternatively, if you do not have access or don't want to install it there, simply add an alias to your `.bash_profile` or `.bashrc` (_and don't forget to `source` them after!_):
```bash
alias ="sh ~/path/to/.sh"
```
Now you should be able to run the program from any directory.
```bash
--version
```
### Contributing
Please feel free to open an issue or pull request if you notice any bugs. If you find that there is anything missing that you commonly use, please add it.
### Attribution
If you would like to provide attribution, you can do so by linking to this repository (https://github.com/qjack001/bash-template), but it is not required.
### Examples
Projects which use this template:
- [`todo`](https://github.com/qjack001/todo) — A simple todo-list app (doesn't use the template verbatim, but does use most of it).
- [`jit`](https://github.com/qjack001/jit) — A `git` replacment that's more like Github Desktop (doesn't use the template at all, but rather the template was made based on how I did things there).