mirror of
https://github.com/DictXiong/dotfiles.git
synced 2026-10-24 13:48:15 +08:00
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:
27
functions/_scf
Normal file
27
functions/_scf
Normal 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 "$@"
|
||||
Reference in New Issue
Block a user