]> git.armaanb.net Git - charsel.git/blobdiff - charsel
added version check function
[charsel.git] / charsel
diff --git a/charsel b/charsel
index d7deba7801b2c9adc87817316c33e8e6b4488244..7938a1c251847e106e55ddad6a63fb33b6b75242 100755 (executable)
--- a/charsel
+++ b/charsel
@@ -19,7 +19,7 @@
 
 ########################################################################
 
-VERSION=2.0.7
+VERSION=2.0.8
 
 # Define argument functions
 function usage() {
@@ -33,7 +33,8 @@ A simple terminal character selector
   -L         show installed charfiles without the message
   -l         show installed charfiles
   -n         dont copy character to clipboard, avoids Xclip dependency
-  -v         print version
+  -V         check for updates
+  -v         print current version
 
 Exit status:
    0         okay,
@@ -43,6 +44,18 @@ Exit status:
    4         other error"
 }
 
+function version_check(){
+  NEW_VERSION=$(curl -s https://codeberg.org/armaan/charsel/raw/branch/master/charsel \
+    | grep VERSION= | tail -c +9)
+  if [[ $VERSION != $NEW_VERSION ]]
+  then
+    echo "an update is available"
+  else
+    echo "you are up to date"
+  fi
+
+}
+
 CHARDIR=$HOME/.cache/charsel
 function list() {
   ls $CHARDIR/charfiles
@@ -106,7 +119,7 @@ function validity() {
 }
 
 # Look for arguments
-while getopts ":abcdhlLnv" arg
+while getopts ":abcdhlLnvV" arg
 do
   case ${arg} in
     a)
@@ -143,6 +156,10 @@ do
       echo "charsel" $VERSION
       exit 0
       ;;
+    V)
+      version_check
+      exit 0
+      ;;
     ?)
       echo "Invalid option"
       usage