shell-completion: bash: Add systemd-analyze filesystems

This commit is contained in:
Simon Barth
2025-11-10 22:27:57 +01:00
parent ceb67d42f5
commit 62aba7c5cd

View File

@@ -56,6 +56,15 @@ __get_architectures() {
systemd-analyze --no-legend --no-pager architectures 2>/dev/null | { while read -r a b; do echo " $a"; done; }
}
__get_filesystem_sets() {
local line
systemd-analyze filesystems --no-pager 2>/dev/null | while IFS= read -r line; do
if [[ $line == @* ]]; then
printf '%s\n' "$line"
fi
done
}
_systemd_analyze() {
local i verb comps mode
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
@@ -86,6 +95,7 @@ _systemd_analyze() {
[TRANSIENT_SETTINGS]='transient-settings'
[UNIT_SHELL]='unit-shell'
[UNIT_GDB]='unit-gdb'
[FILESYSTEMS]='filesystems'
)
local CONFIGS='locale.conf systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
@@ -265,6 +275,13 @@ _systemd_analyze() {
else
comps=$( __get_services $mode )
fi
elif __contains_word "$verb" ${VERBS[FILESYSTEMS]}; then
if [[ $cur = -* ]]; then
comps='--help --version --no-pager'
else
comps=$( __get_filesystem_sets )
fi
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )