diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-25 15:24:10 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-26 23:16:58 -0500 |
commit | 1883552c3d80d44f4cb368874d54c1cb15b83e61 (patch) | |
tree | 0cb7b9abd2896a0e30a8ada0ca6a6c25efd819af /shell-completion/systemd-bash-completion.sh | |
parent | 3679d1126bae52e02f6cd60fca196f616b9e660d (diff) |
bash-completion: journalctl query by binary and device
The approach taken is different between the two:
- since there are many files in /usr, but messages appear
only for a tiny subset, the completion is performed
only for stuff shown by journalctl -F _EXE. This makes
sense because the list is already in proper form.
- since it is hard to convert _KERNEL_DEVICE to device
file name, simply all files in /dev/ are used as possible
completions.
Unfortunately zsh completion requires more work and is not
covered by this commit.
Diffstat (limited to 'shell-completion/systemd-bash-completion.sh')
-rw-r--r-- | shell-completion/systemd-bash-completion.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/shell-completion/systemd-bash-completion.sh b/shell-completion/systemd-bash-completion.sh index 1132b3c028..7848bafc17 100644 --- a/shell-completion/systemd-bash-completion.sh +++ b/shell-completion/systemd-bash-completion.sh @@ -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") ) |