Skip to content

Instantly share code, notes, and snippets.

@snaewe
Created November 3, 2016 07:16
Show Gist options
  • Save snaewe/79734a6709c0a0bd95c68263d99f652b to your computer and use it in GitHub Desktop.
Save snaewe/79734a6709c0a0bd95c68263d99f652b to your computer and use it in GitHub Desktop.
run anything under sudo
#!/bin/bash
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
case ${0##*/} in
sudify)
if [ $# -eq 1 ]; then
pushd ${0%/*} > /dev/null
if [ -e $1 ]; then
echo "ERROR: Can't sudify $1"
popd > /dev/null
exit 1
else
ln -s sudify $1
fi
popd > /dev/null
else
echo "sudify <command>"
exit 1
fi
;;
*)
$(which sudo) $(which ${0##*/}) $@
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment