#!/bin/bash declare subcommand="$1"; shift declare -r gold=$'\033[38;2;250;130;10m' declare -r cyan=$'\033[38;2;0;255;255m' declare -r reset=$'\033[0m' ziplink () { if [[ -z "$1" ]]; then echo "usage: gh ziplink /" fi curl -s "https://api.github.com/repos/$1/releases/latest" |jq -r .zipball_url } zipball () { if [[ -z "$1" ]]; then echo "usage: gh zipball /" fi declare link=$(ziplink "$1") declare file=${1##*/}.${link##*/}.zip echo "${gold}Downloading ${cyan}$link$reset -> ${cyan}$file$reset" curl -s -L "$link" -o "$file" } declare -a commands=(ziplink zipball) for i in ${commands[@]}; do if [[ $i == "$subcommand" ]]; then "$subcommand" $* exit 0 fi done ######################### Tab Completion Context ######################## # remember COMP_LINE is changed by shift if [ -n "$COMP_LINE" ]; then for cmd in ${commands[@]}; do [[ "${cmd:0:${#1}}" == "$1" ]] && echo $cmd done exit 0 fi