You are not logged in.

#1 2011-05-20 16:30:48

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,788
Website

systemctl (systemd) zsh autocomplete

Has anyone created a zsh command completion script for systemctl? If so, would you mind sharing on the AUR?

In my mind, it should work like so:

---
systemctl en[TAB] wic[TAB]
#evaluates to
systemctl enable wicd.service
#
systemctl rest[TAB] get[TAB][TAB]
#evaluates to
systemctl restart getty@tty
getty@tty1.service   getty@tty2.service   (etc)
---

For {COMMAND}, it should obviously expand to list-units, start, stop, reload, restart, try-restart, reload-or-restart, reload-or-try-restart, isolate, kill, is-active, status, show, reset-failed, enable, disable, is-enabled, load, list-jobs, cancel, monitor, dump, dot, snapshot, delete, daemon-reload, daemon-reexec, show-environment, set-environment, unset-environment, default, rescue, emergency, halt, poweroff, reboot, kexec, or exit.

As for [NAME...], it's gonna be a lot more complicated. Depending on the COMMAND, it should search through the relevant files in /lib/systemd/system/ and /etc/systemd/system, or the currently enabled services, or the currently running services, etc.

If nobody's made/in the process of making something like this, I'll give it a go when I have the time. Although I'd probably just focus on the start, restart, stop, enable, disable, poweroff and reboot, since those are the only commands I use.

smile


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#2 2011-08-25 20:59:45

foudfou
Member
Registered: 2011-08-25
Posts: 4

Re: systemctl (systemd) zsh autocomplete

I have written one:
https://github.com/foudfou/zsh-completi … _systemctl (comments very welcome)

Note also that systemd sources include systemctl-bash-completion.sh, but I
wasn't able to use it with bashcompinit.

Offline

#3 2011-08-26 02:08:10

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,788
Website

Re: systemctl (systemd) zsh autocomplete

Awesome, thanks. I did make a start on my own, but I couldn't get it to work properly. You might want to write up a PKGBUILD and submit it to the AUR so more people can find it (here's the PKGBUILD I wrote up to install it on my PC, which'll save you ~20 seconds of writing).

AUR submission instructions are here.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

#4 2013-09-26 08:24:22

vermelho
Member
Registered: 2012-05-02
Posts: 8

Re: systemctl (systemd) zsh autocomplete

Systemctl autocomplete for zsh broke in my machine at some update, it used to be working alright.

Offline

#5 2013-09-26 08:30:14

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,466

Re: systemctl (systemd) zsh autocomplete

I'm sure that has nothing to do with this two year old thread.

https://wiki.archlinux.org/index.php/Fo … Bumping.22

Offline

#6 2013-09-26 08:33:29

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: systemctl (systemd) zsh autocomplete

Indeed. Closing.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB