Created
July 20, 2022 17:20
-
-
Save p-x9/dfb28450764a18daaf4a3321e4f0db16 to your computer and use it in GitHub Desktop.
rootに変わってお仕置きされます
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
# add the following code to your .bashrc | |
sudo() { | |
local ARGS="${@:1}" | |
while (( $# > 0 )) | |
do | |
case $1 in | |
-u | --user | --user=*) | |
if [[ "$1" =~ ^--user= ]]; then | |
local SELECTED_USER=$(echo $1 | sed -e 's/^--user=//') | |
elif [[ -z "$2" ]] || [[ "$2" =~ ^-+ ]]; then | |
: | |
else | |
local SELECTED_USER=$2 | |
shift | |
fi | |
;; | |
*) | |
local COMMAND=$1 | |
;; | |
esac | |
shift | |
done | |
if [[ -z "${COMMAND}" ]] && [[ -z "${SELECTED_USER}" ]]; then | |
: | |
else | |
echo "${SELECTED_USER}に変わって${COMMAND}よ" | |
fi | |
/usr/bin/sudo $ARGS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment