Created
May 12, 2016 02:26
-
-
Save omni-/2c1ee92dc257f03cff1c576f05543ac9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
es() { | |
local OPTIND | |
python='' | |
elevated='' | |
file='' | |
while getopts 'f:ps' flag; do | |
case "${flag}" in | |
f) file="${OPTARG}" ;; | |
p) python='true' ;; | |
s) elevated='true' ;; | |
\?) echo "E: Unrecognized option ${flag}" && return ;; | |
esac | |
done | |
if [ $# -eq 0 ] ; then | |
echo "E: Not enough args" && return | |
fi | |
if [ -z "${file}" ] ; then | |
echo "E: Must specify file" && return | |
fi | |
sPath="$scripts/$file" | |
if [ ! -f "$sPath" ] ; then | |
echo "E: File not found" | |
else | |
chmod a+x $sPath | |
if [ "$python" = "true" ] ; then | |
python $sPath | |
elif [ "$elevated" = "true" ] ; then | |
sudo -s . $sPath | |
else | |
. $sPath | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment