]> git.armaanb.net Git - charsel.git/blobdiff - charsel
added math charfile
[charsel.git] / charsel
diff --git a/charsel b/charsel
index 8270ff3ed0546463f220a653305507f846986a3d..6fb47d21309070a9936967e617215b7b19c56cb4 100755 (executable)
--- a/charsel
+++ b/charsel
 
 VERSION=2.0.7
 
-# Environment variables
-
 # Define argument functions
 function usage() {
   echo "Usage: /usr/bin/charsel [OPTION]... [CHARFILE]...
 A simple terminal character selector
+  -a         include hidden shortcodes
+  -b         disable color support
+  -c         check charfile validity
+  -d         show readme
   -h         show this message
-  -l         show installed charfiles
   -L         show installed charfiles without the message
-  -d         show readme
+  -l         show installed charfiles
+  -n         dont copy character to clipboard, avoids Xclip dependency
   -v         print version
-  -c         check charfile validity
-  -a         include hidden shortcodes
 
 Exit status:
    0         okay,
@@ -110,9 +110,23 @@ if [ $# -eq 0 ]; then
   usage
   exit 3
 fi
-while getopts ":aLlchdv" arg
+while getopts ":abcdhlLnv" arg
 do
   case ${arg} in
+    a)
+      SHOWALL="true"
+      ;;
+    b)
+      COLOR="bw"
+      ;;
+    c)
+      validity
+      exit 0
+      ;;
+    d)
+      readme
+      exit 0
+      ;;
     h)
       usage
       exit 0
@@ -126,21 +140,13 @@ do
       list
       exit 0
       ;;
-    d)
-      readme
-      exit 0
-      ;;
+    n)
+      COPY="no"
+      ;; 
     v)
       echo "charsel" $VERSION
       exit 0
       ;;
-    c)
-      validity
-      exit 0
-      ;;
-    a)
-      SHOWALL="true"
-      ;;
     ?)
       echo "Invalid option"
       usage
@@ -156,9 +162,18 @@ existence
 validity
 
 # Dependency check
-if [[ -x xclip ]]
+if [[ ! $COPY == "no" ]]
+then
+  if [[ -x xclip ]]
+  then
+    echo "Please install xclip."
+    exit 4
+  fi
+fi
+
+if [[ $(echo $LANG | grep UTF-8) -ne 0 ]]
 then
-  echo "Please install xclip."
+  echo "Please enable unicode support"
   exit 4
 fi
 
@@ -174,12 +189,21 @@ clear
 bold=$(tput bold)
 normal=$(tput sgr0)
 
+if [[ $COLOR == bw ]]
+then
+  magenta=$(tput setaf 7)
+else
+  magenta=$(tput setaf 5)
+fi
+
+white=$(tput setaf 7)
+
 # Main program
 while true
 do
   # Format output
   echo "*---------*---------------*"
-  echo "| ${bold}CHARSEL${normal} |" $1
+  echo "| ${bold}${magenta}CHARSEL${white}${normal} |" $1
   echo "*---------*---------------*"
   echo ""
 
@@ -223,7 +247,10 @@ do
     fi
 
     # Copy output to clipboard
-    echo -n $OUTPUT | xclip -selection clipboard
+    if [[ ! $COPY == "no" ]]
+    then
+      echo -n $OUTPUT | xclip -selection clipboard
+    fi
 
     clear
   fi