Add a script for adding bash
profile files
This commit is contained in:
parent
7a228d3690
commit
d601f09a9c
1 changed files with 27 additions and 0 deletions
27
scripts/Common/Config/bash/profile.sh
Executable file
27
scripts/Common/Config/bash/profile.sh
Executable 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";
|
||||
}
|
Loading…
Reference in a new issue