X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=shell-completion%2Fsystemd-bash-completion.sh;h=40e66e9d103d477f08cd88a42994f2292922f1bd;hp=1132b3c0288ecdfb319ccd29e7d868da6ed03531;hb=076a24adf4bfbb9c5aa8167e102c253c7e1c651e;hpb=1700761b0678a5f5b43dc5224a97cc1922f74fad diff --git a/shell-completion/systemd-bash-completion.sh b/shell-completion/systemd-bash-completion.sh index 1132b3c02..40e66e9d1 100644 --- a/shell-completion/systemd-bash-completion.sh +++ b/shell-completion/systemd-bash-completion.sh @@ -300,7 +300,7 @@ _journalctl() { -h --help -l --local --new-id128 -m --merge --no-pager --no-tail -q --quiet --setup-keys --this-boot --verify --version --list-catalog --update-catalog' - [ARG]='-D --directory -F --field -o --output -u --unit' + [ARG]='-D --directory -F --field -o --output -u --unit --user-unit' [ARGUNKNOWN]='-c --cursor --interval -n --lines -p --priority --since --until --verify-key' ) @@ -320,6 +320,9 @@ _journalctl() { --unit|-u) comps=$(journalctl -F '_SYSTEMD_UNIT') ;; + --user-unit) + comps=$(journalctl -F '_SYSTEMD_USER_UNIT') + ;; *) return 0 ;; @@ -334,6 +337,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 / 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") )