]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: add lsfd
authorKarel Zak <kzak@redhat.com>
Thu, 2 Oct 2025 12:35:43 +0000 (14:35 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 3 Oct 2025 11:25:18 +0000 (13:25 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
bash-completion/Makemodule.am
bash-completion/lsfd [new file with mode: 0644]
meson.build

index fe92addb13d013baa17696046d42704e998a41c7..3b75ef2314e1acdcbb329db51cc31843adfdc28b 100644 (file)
@@ -222,6 +222,9 @@ endif
 if BUILD_LSBLK
 dist_bashcompletion_DATA += bash-completion/lsblk
 endif
+if BUILD_LSFD
+dist_bashcompletion_DATA += bash-completion/lsfd
+endif
 if BUILD_LSLOCKS
 dist_bashcompletion_DATA += bash-completion/lslocks
 endif
diff --git a/bash-completion/lsfd b/bash-completion/lsfd
new file mode 100644 (file)
index 0000000..193103d
--- /dev/null
@@ -0,0 +1,67 @@
+_lsfd_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+               '-o'|'--output')
+                       local prefix realcur COLLIST
+                       realcur="${cur##*,}"
+                       prefix="${cur%$realcur}"
+                       COLLIST="$(lsfd --list-columns 2>/dev/null | awk '{print $1}' | tail -n +2)"
+                       COMPREPLY=( $(compgen -P "$prefix" -W "$COLLIST" -- $realcur) )
+                       return 0
+                       ;;
+               '-p'|'--pid')
+                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       return 0
+                       ;;
+               '-i'|'--inet')
+                       COMPREPLY=( $(compgen -W "4 6" -- $cur) )
+                       return 0
+                       ;;
+               '-Q'|'--filter'|'-C'|'--counter')
+                       COMPREPLY=( $(compgen -W "expr" -- $cur) )
+                       return 0
+                       ;;
+               '--summary')
+                       COMPREPLY=( $(compgen -W "never only append" -- $cur) )
+                       return 0
+                       ;;
+               '--hyperlink')
+                       COMPREPLY=( $(compgen -W "auto never always" -- $cur) )
+                       return 0
+                       ;;
+               '-h'|'--help'|'-V'|'--version'|'-H'|'--list-columns')
+                       return 0
+                       ;;
+       esac
+       case $cur in
+               -*)
+                       OPTS="
+                               --noheadings
+                               --output
+                               --version
+                               --help
+                               --json
+                               --raw
+                               --threads
+                               --notruncate
+                               --pid
+                               --inet
+                               --filter
+                               --debug-filter
+                               --summary
+                               --counter
+                               --dump-counters
+                               --list-columns
+                               --hyperlink
+                       "
+                       COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       return 0
+}
+complete -F _lsfd_module lsfd
index 4c36e7f91a59fc844e3bc306ef9c8dbc7fa5b1b9..aff99dab9efe75be8c422520bbba7dca4c4a599e 100644 (file)
@@ -3014,6 +3014,7 @@ exe = executable(
 if opt and not is_disabler(exe)
   exes += exe
   manadocs += lsfd_manadocs
+  bashcompletions += ['lsfd']
 endif
 
 exe = executable(