summaryrefslogtreecommitdiff
path: root/home/scripts/system_name.sh
diff options
context:
space:
mode:
Diffstat (limited to 'home/scripts/system_name.sh')
-rwxr-xr-xhome/scripts/system_name.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/home/scripts/system_name.sh b/home/scripts/system_name.sh
new file mode 100755
index 0000000..92b714a
--- /dev/null
+++ b/home/scripts/system_name.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+platform="$(platform.sh)"
+
+MACHINE="$HOST"
+if [ "$platform" = "osx" ]; then
+ MACHINE="$(scutil --get ComputerName)"
+elif [ "$platform" = "linux" ]; then
+ MACHINE="$(cat /proc/sys/kernel/hostname)"
+fi
+
+echo $MACHINE | awk -F\. '{print $1}' \
+ | tr '[:upper:]' '[:lower:]' \
+ | tr ' ' '-'