add create script

This commit is contained in:
Guilherme Rugai Freire 2021-08-14 11:29:37 -03:00
parent 3112769549
commit 2ef16c6f94
No known key found for this signature in database
GPG Key ID: 0F9FE41723A8A297
3 changed files with 46 additions and 0 deletions

1
bin/create-script Symbolic link
View File

@ -0,0 +1 @@
../create-script/create-script.sh

4
create-script/README.md Normal file
View File

@ -0,0 +1,4 @@
# Create script
## About
a simple way to create a script folder structure as well as linking it to the bin folder

41
create-script/create-script.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
fail() {
echo "Fatal error: $1"
exit 1
}
NAME=$1
if [ -z "$NAME" ]; then
echo "Usage: create-script [name]"
exit 1;
fi
[ -f "$HOME/.scripts/bin/$NAME" ] && fail "script already exists"
echo "Creating script folder"
cd "$HOME/.scripts" || exit 1
mkdir "$NAME" || exit 1
echo "Creating README.md"
echo "\
# $NAME
## About
-- about section here --
## Requirements
-- any requirements --"\
> "$NAME/README.md" || exit 1
echo "Creating $NAME.sh"
echo "\
#!/bin/sh"\
> "$NAME/$NAME.sh" || exit 1
echo "Linking $NAME.sh to bin folder"
chmod +x "$NAME/$NAME.sh" || exit 1
ln -s -r "$NAME/$NAME.sh" "bin/$NAME" || exit 1
echo "Done"