update lservices function
This commit is contained in:
parent
f41365f915
commit
fc157b8105
|
@ -99,7 +99,7 @@ backupcp() { mkdir $HOME/.backups/; cp -r --backup=t "$1" "$HOME"/.backups/; }
|
|||
md() { mkdir -pv "$1" && cd "$1"; }
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# list almost all services units (except user disabled) with state color
|
||||
# list almost all services and scopes units (except user disabled) with state color
|
||||
lservices() {
|
||||
Help() {
|
||||
cat <<- HEREDOC
|
||||
|
@ -140,11 +140,11 @@ lservices() {
|
|||
fi
|
||||
|
||||
if [[ "$_UID" == "0" ]]; then
|
||||
local _OUT=$(sudo systemctl list-units --system -q --plain --full --no-pager -t service)
|
||||
local _OUT=$(sudo systemctl list-units --system -q --plain --full --no-pager -t service,scope | sort)
|
||||
elif [[ "$_UID" == "$(id -u)" ]]; then
|
||||
local _OUT=$(systemctl list-units --user -q --plain --full --no-pager -t service)
|
||||
local _OUT=$(systemctl list-units --user -q --plain --full --no-pager -t service,scope | sort)
|
||||
else
|
||||
local _OUT=$(sudo machinectl -q shell --uid="$_UID" .host /usr/bin/systemctl list-units --user -q --plain --full --no-pager -t service)
|
||||
local _OUT=$(sudo machinectl -q shell --uid="$_UID" .host /usr/bin/systemctl list-units --user -q --plain --full --no-pager -t service,scope | sort)
|
||||
fi
|
||||
|
||||
if [[ $_XCLIP == 1 ]]; then
|
||||
|
@ -163,12 +163,12 @@ lservices() {
|
|||
map["exited"] = yellow
|
||||
map["failed"] = red
|
||||
}
|
||||
match($0,/^(.*)\.service(\s*)loaded\s[a-z]+\s([a-z]+)(\s.*)$/,a) {
|
||||
status = a[3]
|
||||
match($0,/^(.*)\.([a-z]+)(\s*)loaded\s[a-z]+\s([a-z]+)(\s.*)$/,a) {
|
||||
status = a[4]
|
||||
if ( status in map )
|
||||
$0 = blue a[1] a[2] reset " " uid " " map[status] status reset a[4]
|
||||
$0 = blue a[1] a[3] a[2] reset " " uid " " map[status] status reset a[5]
|
||||
else
|
||||
$0 = blue a[1] a[2] reset " " uid " " a[3] a[4]
|
||||
$0 = blue a[1] a[3] a[2] reset " " uid " " a[4] a[5]
|
||||
}
|
||||
{ print } '
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue