From 9a01507ab5f4a0c9244c7ca26d24bf0393769716 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Jan 2025 18:27:51 +0100 Subject: [PATCH] Usage of ccze for tail, journalctl and cless --- .zshrc.d/ctools.zsh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.zshrc.d/ctools.zsh b/.zshrc.d/ctools.zsh index 457d856..593b18d 100644 --- a/.zshrc.d/ctools.zsh +++ b/.zshrc.d/ctools.zsh @@ -1,16 +1,25 @@ -ccat(){ - cat $* | sed -u "s/ERROR/$(tput setaf 1)&$(tput sgr0)/gI"|sed -u "s/WARNING/$(tput setaf 3)&$(tput sgr0)/gI"|sed -u "s/INFO/$(tput setaf 2)&$(tput sgr0)/gI"|sed -u "s/DEBUG/$(tput setaf 6)&$(tput sgr0)/gI" +TAIL_CMD=`which tail` +JOURNALCTL_CMD=`which journalctl` + +tail () { + if grep -q -i "\-f" <<< "$*" + then + $TAIL_CMD $* | ccze -A + else + $TAIL_CMD $* + fi } -cless(){ - ccat $* | less -r +journalctl () { + if grep -q "\-f" <<< "$*" + then + $JOURNALCTL_CMD $* | ccze -A + else + $JOURNALCTL_CMD $* + fi } -ctail(){ - tail $* | ccat -} - -cgrep(){ - grep $* | ccat +cless () { + cat $1 | ccze -A | less -R }