2024-03-04 00:34:39 +03:00
|
|
|
# Su shortcut for lazy me.
|
|
|
|
# Root by default.
|
|
|
|
# Usage: s [USER]
|
|
|
|
function s() {
|
2024-03-11 23:13:18 +03:00
|
|
|
su - ${1}
|
2024-03-11 21:47:51 +03:00
|
|
|
}
|
|
|
|
|
2024-03-13 05:42:21 +03:00
|
|
|
# Run something as root. Runs command as a current user if su is not available.
|
2024-03-11 21:47:51 +03:00
|
|
|
# Usage: sudo <COMMAND>
|
|
|
|
function sudo() {
|
2024-03-13 13:07:28 +03:00
|
|
|
if command -v su &> /dev/null; then
|
2024-03-13 05:42:21 +03:00
|
|
|
su -c "$(echo ${*} | tr '\n' ' ')"
|
|
|
|
else
|
|
|
|
${*}
|
|
|
|
fi
|
|
|
|
|
2024-03-04 00:34:39 +03:00
|
|
|
}
|
2024-03-10 08:25:49 +03:00
|
|
|
|
|
|
|
function _complete_s() {
|
2024-03-29 05:35:15 +03:00
|
|
|
_autocomplete_first $(_get_users)
|
2024-03-10 08:25:49 +03:00
|
|
|
}
|
2024-03-11 23:13:18 +03:00
|
|
|
|
2024-03-10 08:25:49 +03:00
|
|
|
complete -F _complete_s s
|
2024-03-11 21:47:51 +03:00
|
|
|
complete -F _autocomplete_nested sudo
|