https://github.com/uetchy/license
A simple zsh function generates LICENSE file.
https://github.com/uetchy/license
Last synced: 4 months ago
JSON representation
A simple zsh function generates LICENSE file.
- Host: GitHub
- URL: https://github.com/uetchy/license
- Owner: uetchy
- License: cc0-1.0
- Created: 2019-01-31T05:17:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-31T05:23:43.000Z (over 7 years ago)
- Last Synced: 2025-02-21T19:27:45.752Z (over 1 year ago)
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# license
A simple zsh function generates `LICENSE` file from [license-templates](https://github.com/licenses/license-templates).
## Usage
```bash
license
license apache
license cc0
license # default to `mit`
```
See [available licenses](https://github.com/licenses/license-templates/tree/master/templates).
## Source Code
```shell
license() {
license_name=${@:-mit}
endpoint="https://raw.githubusercontent.com/licenses/license-templates/master/templates/${license_name}.txt"
year=$(date +%Y)
username=$(git config user.name)
email=$(git config user.email)
organization="${username} <${email}>"
license_body=$(curl -s ${endpoint})
if [ $? != 0 ] || [ $license_body = "404: Not Found" ]; then
echo "No such license: ${@}"
return
fi
license_body=${license_body//"{{ year }}"/${year}}
license_body=${license_body//"{{ organization }}"/${organization}}
echo ${license_body} >/dev/stdout >LICENSE
echo "\nSaved to ./LICENSE"
}
```