From: Samir Benmendil Date: Mon, 19 Sep 2022 10:44:46 +0000 (+0100) Subject: zsh/motd: print if linux version is outdated X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/f58ca98c9db47aa5ca7f5415fdd658fe3b72d24f zsh/motd: print if linux version is outdated --- diff --git a/bin/kercmp b/bin/kercmp new file mode 100755 index 0000000..af3fcba --- /dev/null +++ b/bin/kercmp @@ -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 diff --git a/zsh/lib/motd.zsh b/zsh/lib/motd.zsh index c496767..409726f 100644 --- a/zsh/lib/motd.zsh +++ b/zsh/lib/motd.zsh @@ -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