diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 5d1cc174c9..e7b8d57902 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -94,7 +94,11 @@ _journalctl() { compopt -o nosort ;; --unit|-u) - comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null) + if __contains_word "--user" ${COMP_WORDS[*]}; then + comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null) + else + comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null) + fi # Similarly to systemctl, we need to distinguish between # escaped and unescaped names in order to be able to correctly # complete them. In this particular case, if the name we're @@ -109,6 +113,10 @@ _journalctl() { ;; --user-unit) comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null) + if ! [[ $cur =~ '\\' ]]; then + cur="$(printf '%q' $cur)" + fi + compopt -o filenames ;; --identifier|-t|--exclude-identifier|-T) comps=$(journalctl -F 'SYSLOG_IDENTIFIER' 2>/dev/null)