]> git.armaanb.net Git - charsel.git/blobdiff - charsel
updated readme
[charsel.git] / charsel
diff --git a/charsel b/charsel
index 6fb47d21309070a9936967e617215b7b19c56cb4..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,11 +119,7 @@ function validity() {
 }
 
 # Look for arguments
-if [ $# -eq 0 ]; then
-  usage
-  exit 3
-fi
-while getopts ":abcdhlLnv" arg
+while getopts ":abcdhlLnvV" arg
 do
   case ${arg} in
     a)
@@ -147,6 +156,10 @@ do
       echo "charsel" $VERSION
       exit 0
       ;;
+    V)
+      version_check
+      exit 0
+      ;;
     ?)
       echo "Invalid option"
       usage
@@ -156,6 +169,11 @@ do
 done
 shift $((OPTIND-1))
 
+if [ $# -eq 0 ]; then
+  echo "Please enter a valid charfile, or use charsel -h for help."
+  charsel -l
+  exit 3
+fi
 # Redefine charfile and check file validity
 CHARFILE="$CHARDIR/charfiles/$1"
 existence