diff --git a/.zshrc.d/functions.zsh b/.zshrc.d/functions.zsh index 89d1846..ee478de 100644 --- a/.zshrc.d/functions.zsh +++ b/.zshrc.d/functions.zsh @@ -41,3 +41,24 @@ EOF ) | bat -p } +## fetch open source license +license() { + local base_url + base_url="https://api.github.com/licenses" + + local headers + headers="Accept: application/vnd.github.drax-preview+json" + + local res + if (( $# == 0 )); then + res=$(curl --silent --header $headers $base_url) + + echo "Available licenses:" + echo + echo "$res" | jq ".[].key" | tr -d '"' + fi + + local license="$argv[1]" + res=$(curl --silent --header $headers $base_url/$license | jq ."body") + echo -e $res | tr -d '"' +}