浏览代码

Usage of ccze for tail, journalctl and cless

master
root 4 天前
父节点
当前提交
9a01507ab5
共有 1 个文件被更改,包括 18 次插入9 次删除
  1. 18
    9
      .zshrc.d/ctools.zsh

+ 18
- 9
.zshrc.d/ctools.zsh 查看文件

@@ -1,16 +1,25 @@
1
-ccat(){
2
-    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"
3
-}
1
+TAIL_CMD=`which tail`
2
+JOURNALCTL_CMD=`which journalctl`
4 3
 
5
-cless(){
6
-    ccat $* | less -r
4
+tail () {
5
+    if grep -q -i "\-f" <<< "$*"
6
+    then
7
+        $TAIL_CMD $* | ccze -A
8
+    else
9
+        $TAIL_CMD $*
10
+    fi
7 11
 }
8 12
 
9
-ctail(){
10
-    tail $* | ccat
13
+journalctl () {
14
+    if grep -q "\-f" <<< "$*"
15
+    then
16
+        $JOURNALCTL_CMD $* | ccze -A
17
+    else
18
+        $JOURNALCTL_CMD $*
19
+    fi
11 20
 }
12 21
 
13
-cgrep(){
14
-    grep $* | ccat
22
+cless () {
23
+    cat $1 | ccze -A | less -R
15 24
 }
16 25
 

正在加载...
取消
保存