From d3f9d1abe025601b90aa2da4abeb676422996b18 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 25 Jan 2020 19:41:15 +0100 Subject: [PATCH] Autocompletion of journal command --- .zsh/functions/_journal | 13 +++++++++++++ .zshrc | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .zsh/functions/_journal diff --git a/.zsh/functions/_journal b/.zsh/functions/_journal new file mode 100644 index 0000000..72abe5b --- /dev/null +++ b/.zsh/functions/_journal @@ -0,0 +1,13 @@ +#compdef journal + +__systemctl () { + systemctl $_sys_service_mgr --full --no-legend --no-pager "$@" 2> /dev/null +} + +(( $+functions[_journal_units] )) || _systemctl_get_non_template_names () { + echo -E - ${^${(R)${(f)"$( + __systemctl $mode list-unit-files "$PREFIX*" + __systemctl $mode list-units --all "$PREFIX*" + )"}:#*@.*}%%[[:space:]]*} +} +_wanted systemd-units expl unit compadd "$@" - $(_systemctl_get_non_template_names) \ No newline at end of file diff --git a/.zshrc b/.zshrc index 801863a..b53a35f 100644 --- a/.zshrc +++ b/.zshrc @@ -2,7 +2,7 @@ # Oh my zsh -export ZSH="/r/arisu/.oh-my-zsh" +export ZSH="$HOME/.oh-my-zsh" plugins=(git) COMPLETION_WAITING_DOTS="true" ZSH_THEME="powerlevel10k/powerlevel10k" # `p10k configure` @@ -18,6 +18,7 @@ export LANG=en_US.UTF-8 # Auto completion +fpath=(~/.zsh/functions $fpath) autoload -U compinit zstyle ':completion:*' menu select zmodload zsh/complist @@ -38,10 +39,16 @@ VISUAL=$EDITOR ## Aliases ## +setopt complete_aliases -alias dotgit='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' +alias dotgit='git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' alias authy="/usr/bin/electron4 --app /usr/lib/authy/app.asar" +alias syslog="sudo journalctl -f | ccze" +journal() { + sudo journalctl -f -u $1 | ccze +} + # Random chars rndanchars() { openssl rand -base64 $1 | sed ':a;N;$!ba;s/\n//g' | sed 's/[+\/=]//g' | head -c $1