Skip to content

Instantly share code, notes, and snippets.

@DasFranck
Last active April 26, 2018 23:09
Show Gist options
  • Save DasFranck/7fc7f1d23cc09d15950fdc2d8036a48c to your computer and use it in GitHub Desktop.
Save DasFranck/7fc7f1d23cc09d15950fdc2d8036a48c to your computer and use it in GitHub Desktop.
A shell function showing a nice service summary. (thanks to /u/rmw5601for the base function)
rc(){
systemctl list-unit-files --type=service |\
sed 's/.service//g' |\
sed '/static/d' |\
sed '/indirect/d' |\
sed '/systemd/d' |\
sed '/dbus-org/d' |\
sed '/canberra/d'|\
sed '/wpa_supplicant/d' |\
sed '/netctl/d' |\
sed '/rfkill/d' |\
sed '/krb5/d' |\
tail -n+2 |\
head -n -2 |\
sed 's/\(^.*enabled.*$\)/[x] \1/' |\
sed 's/enabled//g' |\
sed 's/\(^.*disabled.*$\)/[ ] \1/' |\
sed 's/disabled//g' |\
sed 's/[ \t]*$//' |\
while read line; do
if [[ $line == *'[x]'* ]]; then
printf "\033[0;32m$line\n"
else
printf "\033[1;30m$line\n"
fi
done
syncthing_status=`systemctl is-active syncthing@${USER}.service`
if [[ $syncthing_status == "active" ]]; then
printf "\033[0;32m[x] syncthing (${USER})\n"
else
printf "\033[1;30m[ ] syncthing (${USER})\n"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment