From d601f09a9ca44f6c900eae219b5ad17094bdf9ed Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Wed, 20 Mar 2024 21:08:50 +0100
Subject: [PATCH] Add a script for adding `bash` profile files

---
 scripts/Common/Config/bash/profile.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 scripts/Common/Config/bash/profile.sh

diff --git a/scripts/Common/Config/bash/profile.sh b/scripts/Common/Config/bash/profile.sh
new file mode 100755
index 00000000..037e54e1
--- /dev/null
+++ b/scripts/Common/Config/bash/profile.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+function addBashProfile() {
+    name="$1";
+    title="$2";
+
+    if [ -t 1 ]
+    then
+        statement="$(cat)";
+    else
+        statement="${@:3}";
+    fi;
+
+    contextRoot="$(mktemp -d)";
+    pushd "$contextRoot" > /dev/null;
+
+    {
+        echo '#!/bin/bash';
+        echo "# $title";
+        echo "$statement";
+    } > "profile.sh";
+
+    sudo install -Dm755 profile.sh /etc/bash/conf.d/$name.sh
+
+    popd > /dev/null;
+    rm -rf "$contextRoot";
+}