.emacs.d/snippets/sh-mode/script

73 lines
1.8 KiB
Bash

# -*- mode: Shell-script -*-
# name:script
# key:script
# --
#!/usr/bin/env bash
#############################################################
# Author: Taryel Hlontsi, 2025
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>
#############################################################
doc=$(cat <<'EOF'
NOTES:
EOF
)
#############################################################
# SETUP SECTION
#############################################################
set -e
set -o pipefail
#############################################################
# HELPER FUNCTIONS
#############################################################
info() {
GREEN='\033[1;32m'
NC='\033[0m'
echo -e "\${GREEN}\${1}\${NC}"
}
trace() {
YELLOW='\033[1;33m'
NC='\033[0m'
echo -e "\${YELLOW}\${1}\${NC}"
}
warn() {
PURPLE='\033[1;35m'
NC='\033[0m'
echo -e "\${PURPLE}\${1}\${NC}"
}
error() {
RED='\033[1;31m'
NC='\033[0m'
echo -e "\${RED}\${1}\${NC}"
}
$0
#############################################################
# RUN SECTION
#############################################################
echo $(date +'%Y-%m-%d %H:%M')
info "$doc"
info "Bye!"
exit 0