]> git.rmz.io Git - dotfiles.git/commitdiff
zsh/motd: print if linux version is outdated
authorSamir Benmendil <me@rmz.io>
Mon, 19 Sep 2022 10:44:46 +0000 (11:44 +0100)
committerSamir Benmendil <me@rmz.io>
Mon, 19 Sep 2022 10:44:46 +0000 (11:44 +0100)
bin/kercmp [new file with mode: 0755]
zsh/lib/motd.zsh

diff --git a/bin/kercmp b/bin/kercmp
new file mode 100755 (executable)
index 0000000..af3fcba
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+version="0.1"
+
+function usage ()
+{
+    echo "Usage :  $0 [options]
+
+    Options:
+    -h,--help       Display this message
+    -v,--version    Display script version"
+}
+
+# Parse arguments
+declare -a args
+while [[ $# -gt 0 ]]; do
+    opt="$1"
+
+    case $opt in
+        -h|--help)     usage; exit 0 ;;
+        -v|--version)  echo "$0 -- Version $version"; exit 0 ;;
+        -q|--quiet)    quiet=1 ; shift ;;
+        -* )
+            echo -e "\n  Option does not exist : $opt\n"
+            usage; exit 1 ;;
+
+        *) args+=("$opt"); shift ;;
+    esac
+done
+
+running=$(uname -r | sed s/-/./)
+install=$(pacman -Q linux | cut -d' ' -f2)
+vcmp=$(vercmp $running $install)
+
+((${quiet:=0}==1)) && exit $vcmp
+
+(($vcmp<0)) && echo "$running older than $install"
+(($vcmp>0)) && echo "$running newer than $install"
+
+exit $vcmp
index c4967674b160523d3c570e1750fcf3b4e48beb56..409726fec3aa0b29cbbb81b41025b11574b0fd95 100644 (file)
@@ -22,6 +22,9 @@ if (( $+commands[checkupdates] )); then
         short "Outdated packages: $pkg_count"
     fi
 fi
+if (( $+commands[pacman] )); then
+    kercmp -q || short "linux" "$(kercmp)"
+fi
 
 # list sessions if possible
 tmux list-sessions 2>/dev/null || true