chiark / gitweb /
bash-completion: journalctl query by binary and device
[elogind.git] / shell-completion / systemd-bash-completion.sh
index 1132b3c0288ecdfb319ccd29e7d868da6ed03531..7848bafc1784136677f8cc2d7bbadc72ed67a539 100644 (file)
@@ -334,6 +334,20 @@ _journalctl() {
         elif [[ $cur = *=* ]]; then
                 mapfile -t field_vals < <(journalctl -F "${prev%=}" 2>/dev/null)
                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur#=}") )
+        elif [[ $cur = /dev* ]]; then
+                compopt -o filenames
+                COMPREPLY=( $(compgen -f -- "${cur}") )
+        elif [[ $cur = /* ]]; then
+                # Append /dev/ to the list of completions, so that
+                # after typing /<TAB><TAB> the user sees /dev/ as one
+                # of the alternatives. Later on the rule above will
+                # take care of showing device files in /dev/.
+                mapfile -t field_vals < <(journalctl -F "_EXE" 2>/dev/null; echo '/dev/')
+                COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "${cur}") )
+                if [[ "${COMPREPLY[@]}" = '/dev/' ]]; then
+                    compopt -o filenames
+                    COMPREPLY=( $(compgen -f -- "${cur}") )
+                fi
         elif [[ $prev = '=' ]]; then
                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )