Created
April 14, 2023 13:15
-
-
Save zudsniper/02cbc77c60866525ede7f4390048fd51 to your computer and use it in GitHub Desktop.
my template for bash scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# template.sh | |
# --------------- | |
# by @zudsniper on github | |
# not really, its by chatGPT but i guess i get the credit | |
# > im leaving this in the template | |
# | |
# DEPENDENCIES | |
# - thing: it is good | |
# | |
# TODO | |
# - add features | |
# https://bashrc.zod.tf | |
# --------------- | |
# ----------------------------- # | |
## ANSI COLOR ENVIRONMENT VARS | |
# Check if .ansi_colors.sh exists, and if not, download it from Github | |
if [ ! -f "$HOME/.ansi_colors.sh" ]; then | |
echo "${A_LIGHTGREY}Downloading ${A_BOLD}.ansi_colors.sh${A_RESET}${A_LIGHTGRAY}...${A_RESET}" | |
curl -sSf "https://gist.githubusercontent.com/zudsniper/e5bbdb7d3384a2b5f76277b52d103e59/raw/.ansi_colors.sh" > "$HOME/.ansi_colors.sh" | |
fi | |
# source the colors | |
. "$HOME/.ansi_colors.sh" | |
# ----------------------------- # | |
# check OS | |
checkOS() { | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
export opersys="linux" | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
# Mac OSX | |
export opersys="mac" | |
elif [[ "$OSTYPE" == "cygwin" ]]; then | |
# POSIX compatibility layer and Linux environment emulation for Windows | |
export opersys="win-gitbash" | |
elif [[ "$OSTYPE" == "msys" ]]; then | |
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW) | |
export opersys="win-msys" | |
elif [[ "$OSTYPE" == "win32" ]]; then | |
# I'm not sure this can happen. | |
export opersys="win32" | |
elif [[ "$OSTYPE" == "freebsd"* ]]; then | |
# ... | |
export opersys="freebsd" | |
else | |
export opersys="unknown" | |
# Unknown. | |
fi | |
} | |
## _______ OS DETERMINED _______ ## | |
# "${opersys}" | |
checkOS; | |
## _____PUT CODE UNDER THIS ____ ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment