diff --git a/scripts/Common/Config/bash/profile.sh b/scripts/Common/Config/bash/profile.sh index 037e54e1..d0812dd4 100755 --- a/scripts/Common/Config/bash/profile.sh +++ b/scripts/Common/Config/bash/profile.sh @@ -1,27 +1,11 @@ #!/bin/bash +pushd "${BASH_SOURCE%/*}" > /dev/null; +. "../../Scripts/profile-base.sh"; 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"; + addProfileStatement "$name" "$title" "/bin/bash" "/etc/bash/conf.d" "${@:3}"; } + +popd > /dev/null; diff --git a/scripts/Common/Scripts/profile-base.sh b/scripts/Common/Scripts/profile-base.sh new file mode 100755 index 00000000..80c500a4 --- /dev/null +++ b/scripts/Common/Scripts/profile-base.sh @@ -0,0 +1,27 @@ +function addProfileStatement() { + name="$1"; + title="$2"; + shellBin="$3"; + profileRoot="$4"; + + if [ -t 1 ] + then + statement="$(cat)"; + else + statement="${@:5}"; + fi; + + contextRoot="$(mktemp -d)"; + pushd "$contextRoot" > /dev/null; + + { + echo '#!'"$shellBin"; + echo "# $title"; + echo "$statement"; + } > "profile.sh"; + + sudo install -Dm755 profile.sh "$profileRoot/$name.sh" + + popd > /dev/null; + rm -rf "$contextRoot"; +}