summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2022-08-05 09:26:24 -0400
committerGalen Guyer <galen@galenguyer.com>2022-08-05 09:26:24 -0400
commit50631579696f541e6818112095151b917f5f1441 (patch)
treec45a2c773e6ec332af030f4d0a4596d3a61fbc3f
Print intro and detect OS
-rwxr-xr-xdots18
-rw-r--r--lib/os.sh12
2 files changed, 30 insertions, 0 deletions
diff --git a/dots b/dots
new file mode 100755
index 0000000..4e24674
--- /dev/null
+++ b/dots
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+source lib/*
+
+function intro() {
+cat <<EOF
+
+ $(tput setab 4) $(tput sgr0) $(tput bold).dots$(tput sgr0)
+ $(tput setab 4) $(tput sgr0) $(tput bold)version 1$(tput sgr0)
+
+EOF
+}
+
+function main() {
+ intro
+ echo "Running as $(id -un) on $(os::distro)"
+}
+
+main $@
diff --git a/lib/os.sh b/lib/os.sh
new file mode 100644
index 0000000..eff8e9c
--- /dev/null
+++ b/lib/os.sh
@@ -0,0 +1,12 @@
+function os::kernel() {
+ uname -s | tr '[:upper:]' '[:lower:]'
+}
+
+function os::distro() {
+ if [[ "$(os::kernel)" = "linux" ]] && [[ -f /etc/os-release ]]; then
+ source /etc/os-release
+ echo "$ID" | tr '[:upper:]' '[:lower:]' | sed 's/^arch$/archlinux/'
+ return
+ fi
+ echo "unknown"
+}