]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shell-completion: bash: Add systemd-analyze filesystems
authorSimon Barth <simon.barth@gmx.de>
Mon, 10 Nov 2025 21:27:57 +0000 (22:27 +0100)
committerSimon Barth <simon.barth@gmx.de>
Mon, 17 Nov 2025 22:40:58 +0000 (23:40 +0100)
shell-completion/bash/systemd-analyze

index 8d055449412429e12a9c836f10dc9c93ace221a6..a6861013b8dd9ae57d6717b8e4cafddbcbe7b56a 100644 (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") )