Add a script for adding bash profile files

This commit is contained in:
Manuel Thalmann 2024-03-20 21:08:50 +01:00
parent 7a228d3690
commit d601f09a9c

View file

@ -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";
}