Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frzam/hail
Cross-platform script management CLI written in go.
https://github.com/frzam/hail
cli cross-platform golang linux
Last synced: 8 days ago
JSON representation
Cross-platform script management CLI written in go.
- Host: GitHub
- URL: https://github.com/frzam/hail
- Owner: frzam
- License: apache-2.0
- Created: 2021-03-25T18:31:23.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T16:12:40.000Z (over 3 years ago)
- Last Synced: 2024-08-07T22:35:29.905Z (3 months ago)
- Topics: cli, cross-platform, golang, linux
- Language: Go
- Homepage: https://frzam.github.io/hail/
- Size: 1.63 MB
- Stars: 20
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Cross-Platform Scripts Management CLI written in go
[![Go Report Card](https://goreportcard.com/badge/github.com/frzam/hail)](https://goreportcard.com/report/github.com/frzam/hail)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=frzam_hail&metric=alert_status)](https://sonarcloud.io/dashboard?id=frzam_hail)
![example workflow](https://github.com/frzam/hail/actions/workflows/release.yml/badge.svg)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GO Version]( https://img.shields.io/github/go-mod/go-version/frzam/hail
)]( https://img.shields.io/github/go-mod/go-version/frzam/hail
)
[![CII](https://bestpractices.coreinfrastructure.org/badge_static/72)](https://bestpractices.coreinfrastructure.org/en/projects/5082)* [About](#about)
* [Features](#features)
* [Installation](#installation)
* [Linux Or Unix](#linux-or-unix)
* [Windows](#windows)
* [Usage](#usage)
* [License](#license)## About
Today we spend lots of time in terminal and there are lots of command and scripts that we have to remember and if we forget then we have to dig into history to look. **hail** lets you save all those useful and frequently used commands or scripts with some alias so you can use the alias to print or directly run the command in terminal.
**hail** has built in *fuzzy search* so you don't even have to remember complete alias name, you can simply write few alphabets of alias and you will be presented with matching alias.
**hail** also lets you run scripts(python, bash, perl, sh, bat etc) directly from hail provided script starts with **shebang**. Please refer [usage](#usage) section for more details. This project is influenced by [pier](https://github.com/pier-cli/pier) and thank you [Nida](https://www.instagram.com/nida_fatima_khaan) for this beautiful logo.
```
> hail -h
hail is a cross-platform script management toolUsage:
hail [flags]
hail [command]Available Commands:
add add is used to add a new command in collection
completion generate the autocompletion script for the specified shell
config it is used to list or update configurations
copy copy/cp is used to copy one command/script to a new alias
delete delete/rm removes command from hail basis alias
edit edit previously added command or script in text editor
get get retrieves command basis the alias
help Help about any command
init init initializes an empty .hailconfig file with title as provided
list list/ls prints all the alias and commands
move move/mv used to move command with old alias to new alias
run it is used to directly run a command from alias
update updates already present command
version version prints the current version of hailFlags:
-h, --help help for hailUse "hail [command] --help" for more information about a command.
``````
> hail ls
+--------------------+----------------------------------------------------+----------------------+
| ALIAS | COMMAND | DESCRIPTION |
+--------------------+----------------------------------------------------+----------------------+
| list-git-repo | find ~ -name ".git" 2> /dev/null | sed 's/\/.git/\ | |
| | //g' | awk '{print "-------------------------\n\03 | |
| | 3[1;32mGit Repo:\033[0m " $1; system("git --git-di | |
| | r="$1".git --work-tree="$1" status")}' | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| log-with-exception | find . -name '*.log' -mtime -2 -exec grep -Hc Exce | |
| | ption {} \; | grep -v :0$ | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| pv | apiVersion: v1 | Persistence volume i |
| | kind: PersistentVolume | n ocp |
| | metadata: | |
| | name: pv00001 | |
| | spec: | |
| | capacity: | |
| | storage: 10Gi | |
| | accessModes: | |
| | - ReadWriteOnce | |
| | persistentVolumeReclaimPolicy: Retain | |
| | nfs: | |
| | path: /mnt/path | |
| | server: | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| scan-ports | for i in {1..65535}; do (echo < /dev/tcp/127.0.0.1 | |
| | /$i) &>/dev/null && printf "\n[+] Open Port at\n: | |
| | \t%d\n" "$i" || printf "."; done | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| server-sh | `#!/bin/bash | |
| | echo|read|{(read t;g=$(echo $t|cut -d' ' -f2) | |
| | while read|grep :;do :;done;[[ -e .$g &&! $g = | |
| | *..* ]]||exit | |
| | printf "HTTP/1.1 200 OK\nContent-Length: $(sta | |
| | t -c%s .$g)\n\n" | |
| | cat .$g)|nc -l -p $1;}>/dev/fd/0;$0 $1 | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| was-bin | cd /opt/IBM/BPM/v8.6/profiles/managerProfile/bin | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| create-password | tr -dc 'a-zA-Z0-9~!@#$%^&*_()+}{?>";.,[]=-' < /d | generate a password |
| | ev/urandom | fold -w 32 | head -n 1 | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
| disk-usage-by-type | find . -type f -empty -prune -o -type f -printf "% | |
| | s\t" -exec file --brief --mime-type '{}' \; | awk | |
| | 'BEGIN {printf("%12s\t%12s\n","bytes","type")} {ty | |
| | pe=$2; a[type]+=$1} END {for (i in a) printf("%12u | |
| | \t%12s\n", a[i], i)|"sort -nr"}' | |
| | | |
+--------------------+----------------------------------------------------+----------------------+
```## Features
* Cross-Platform
* Auto Completion scripts are available (Bash, fish, zsh and powershell)
* Inbuilt fuzzy searching
* Store commands as well as scripts
* Single and small binary to install. (Thanks to go!)
* Run commands or scripts directly from hail
* Portable toml file *.hailconfig*
* Format of scripts or command is also preserved eg *yaml*## Installation
### Linux or Unix
```python
# Download the latest version of hail from releases https://github.com/frzam/hail/releases/ and unzip the file
> wget -c https://github.com/frzam/hail/releases/download/v0.1.16/hail_0.1.16_Linux_x86_64.tar.gz -O - | tar -xz# Give execute permission to hail and move the binary into bin folder so it is accessible everywhere.
> chmod +x hail | mv hail /usr/local/bin/# Test if hail is working properly.
> hail version# Initialize hailconfig, it will create .hailconfig file under $HOME. If you want to
# create .hailconfig anywhere else then set env HAILCONFIG to that path.
> hail init -i bash
```
#### Set up tab auto completion for bash.
Auto completion scripts are also available for fish and zsh.```python
# Generate bash script in a file
> hail completion bash > ~/.hail# Open ~/.bashrc in editor
> vi ~/.bashrc# Add below line in .bashrc
> source ~/.hail# Refresh .bashrc by doing
> source ~/.bashrc
```
### Windows
```python
# Download the latest binary from releases https://github.com/frzam/hail/releases/# Unzip the hail__Windows_x86_64.tar.gz file into *hail.exe*
# Place hail.exe into the PATH
# Test if hail is working properly. Open Command Prompt, Powershell or Git bash and Run.
> hail version# Initialize hailconfig, it will create .hailconfig file under $USERPROFILE.
# If you want to create .hailconfig anywhere else then set env HAILCONFIG to that path
> hail init -t -i bash# Generate powershell completion script
> hail completion powershell
```
## Usage
```python
# Initialize a .hailconfig file with default interpreter set to bash
> hail init -t my-config -i bash# Add a command and description with alias 'create-password'. Add Command in
# default editor tr -dc 'a-zA-Z0-9~!@#$%^&*_()+}{?>";.,[]=-' < /dev/urandom | fold -w 32 | head -n 1
> hail add -a create-password -d "create a password"# Get a command with alias 'create-password'
> hail get create-password# Edit a command with alias 'create-password'
> hail edit create-password# Run a command with alias 'create-password'
> hail run create-password# Delete an entry with alias 'create-password'
> hail rm create-password# List all aliases with commands and descriptions.
> hail ls# For more info on any sub command.
> hail -h
```
### Run
We can directly run scripts which contains shebang ```#!``` and interpreter as first line.
For example:
```python
#!/usr/bin/env python
user_input=12345
_rev=0
while(user_input>0):
dig=user_input%10
_rev=_rev*10+dig
user_input=user_input//10
print("The reversed number is :",_rev)```
```bash
#!/bin/bash
echo "hello world"
```
hail creates a temp file and takes interpreter(In this case python or bash) from the first line and runs the file with given interpreter, later removes the file. If shebang is not present in the script then the default interpreter is taken from *.hailconfig*To set default interpreter use
```> hail config -n interpreter -v ```
> Note: Run is still in beta stage. Please feel free to reach out to me in case of any doubt at [email protected] and contributions are very welcome :)
# License
hail is provided under [Apache 2.0](https://github.com/frzam/hail/blob/master/LICENSE) license.