feat(scf): Open the configuration file referenced by a systemd service's ExecStart

Signed-off-by: Dict Xiong <me@dxng.cn>
This commit is contained in:
Dict Xiong
2026-08-26 18:01:07 +08:00
parent e88d6a4621
commit 86f74b0a84
4 changed files with 489 additions and 0 deletions

27
functions/_scf Normal file
View File

@@ -0,0 +1,27 @@
#compdef scf
_scf() {
_arguments -s \
'(-r)-r[Recursively inspect referenced files and directories]' \
'(-n)-n[Open candidate number directly]:candidate number:' \
'--[End of options]' \
'1:systemd service:_scf_services'
}
_scf_services() {
local -a services
if (( $+commands[systemctl] )); then
services=("${(@f)$(systemctl list-unit-files --type=service --no-legend --no-pager 2>/dev/null \
| awk '$1 ~ /\.service$/ {print $1}' \
| sort -u)}")
fi
if (( ${#services} > 0 )); then
_describe -t services 'systemd service' services
else
_message 'systemd service'
fi
}
_scf "$@"