commit 31fdd60c63f32cd9fe161f5e3cfd2803b930fb70 parent f8f9cd161eed523ee964c50e439df76a73d6f40c Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Sun, 22 Nov 2020 14:50:40 -0800 Add and use doasroot function This function only invokes doas(1) if the user is not root and makes aliases which run a command through doas functional for root. Diffstat:
| M | modules/shell/.config/shell/main | | | 8 | ++++++-- |
| M | modules/shell/.config/shell/openbsd | | | 9 | +++++---- |
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/modules/shell/.config/shell/main b/modules/shell/.config/shell/main @@ -13,13 +13,17 @@ include() { . "$include" } +alias doas="doas -- " + +# only invoke doas if uid is not 0, define before including openbsd. +doasroot() { test `id -u` -ne 0 && doas $* || $*; } + # Must be included here for ncpu. include openbsd alias ap="apropos" alias apf="apropos -f" -alias doas="doas -- " -alias dsu="doas su" +alias dsu="doasroot su" alias fls="find . -maxdepth 1" alias get="curl -sSLO" alias gmake="gmake -j`ncpu`" diff --git a/modules/shell/.config/shell/openbsd b/modules/shell/.config/shell/openbsd @@ -3,10 +3,11 @@ alias ncpu="sysctl -n hw.ncpufound" # package management -alias pa="doas pkg_add" -alias pd="doas pkg_delete" -alias pi="pkg_info" alias pkg_add="pkg_add -xV" -alias pu="doas pkg_add -u" + +alias pa="doasroot pkg_add" +alias pd="doasroot pkg_delete" +alias pi="pkg_info" +alias pu="doasroot pkg_add -u" pq() { pkglocate "${@}*:*" | cut -d: -f1 | uniq ;}