systemd.plugin.zsh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. user_commands=(
  2. cat
  3. get-default
  4. help
  5. is-active
  6. is-enabled
  7. is-failed
  8. is-system-running
  9. list-dependencies
  10. list-jobs
  11. list-sockets
  12. list-timers
  13. list-unit-files
  14. list-units
  15. show
  16. show-environment
  17. status)
  18. sudo_commands=(
  19. add-requires
  20. add-wants
  21. cancel
  22. daemon-reexec
  23. daemon-reload
  24. default
  25. disable
  26. edit
  27. emergency
  28. enable
  29. halt
  30. hibernate
  31. hybrid-sleep
  32. import-environment
  33. isolate
  34. kexec
  35. kill
  36. link
  37. list-machines
  38. load
  39. mask
  40. poweroff
  41. preset
  42. preset-all
  43. reboot
  44. reenable
  45. reload
  46. reload-or-restart
  47. reset-failed
  48. rescue
  49. restart
  50. revert
  51. set-default
  52. set-environment
  53. set-property
  54. start
  55. stop
  56. suspend
  57. switch-root
  58. try-reload-or-restart
  59. try-restart
  60. unmask
  61. unset-environment)
  62. for c in $user_commands; do; alias sc-$c="systemctl $c"; done
  63. for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
  64. for c in $user_commands; do; alias scu-$c="systemctl --user $c"; done
  65. for c in $sudo_commands; do; alias scu-$c="systemctl --user $c"; done
  66. alias sc-enable-now="sc-enable --now"
  67. alias sc-disable-now="sc-disable --now"
  68. alias sc-mask-now="sc-mask --now"
  69. alias scu-enable-now="scu-enable --now"
  70. alias scu-disable-now="scu-disable --now"
  71. alias scu-mask-now="scu-mask --now"
  72. function systemd_prompt_info {
  73. local unit
  74. for unit in $@; do
  75. echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
  76. [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo -n "${(U)unit}:" || echo -n "$unit:"
  77. if systemctl is-active $unit &>/dev/null; then
  78. echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
  79. else
  80. echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
  81. fi
  82. echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
  83. done
  84. }