]> git.armaanb.net Git - charsel.git/commitdiff
added proper usage
authorArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Sat, 17 Oct 2020 22:52:49 +0000 (18:52 -0400)
committerArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Sat, 17 Oct 2020 22:52:49 +0000 (18:52 -0400)
Makefile
README.md
charsel
usage [new file with mode: 0644]

index d9ffea19fb81c1170b8653ce12176276b40985b9..d34ff02ed78201a1452e0da5f8228f71cc6ba8ef 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ install:
 >cp charfiles/* /usr/share/charsel/charfiles/
 >mkdir /usr/share/doc/charsel
 >cp README.md /usr/share/doc/charsel/
+>cp usage /usr/share/doc/charsel/
 >cp ./charsel /usr/bin/
 
 uninstall:
@@ -23,4 +24,5 @@ reinstall:
 >cp charfiles/* /usr/share/charsel/charfiles/
 >mkdir /usr/share/doc/charsel
 >cp README.md /usr/share/doc/charsel/
+>cp usage /usr/share/doc/charsel/
 >cp ./charsel /usr/bin/
index 7ee46b1c049c2f4fc7c28960e9a182b9970ffd49..295998dcac59bf9c4b41e8236fbb2513dac3e778 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,19 +4,19 @@ A simple bash script to make copying frequently used special characters to your
 It uses a plain-text file known as a "charfile" to define shortcuts to special characters that are easy to access on the keyboard.
 
 ## Installation
-Run `make install` as root to install  
+Run `make install` as root to install
 Run `make uninstall` as root to remove. Will not delete your personal charfiles
 
 ## Dependencies
   * Bash
-  * Linux  
-  * Xclip  
-  * A terminal with UTF-8 encoding enabled  
+  * Linux
+  * Xclip
+  * A terminal with UTF-8 encoding enabled
 
 ## Usage
-To start the program, run `charsel <charfile>`, this will start the program with the specified charfile. There are a few installed by default, to see them, use `charsel list`.
+For usage, use `charsel --help`
 
-Once you have started the program, simply type the shortcut listed on the left side of the table to copy the character on the right side of the table to your clipboard. Shortcodes the same length as the longest one will automatically be entered.
+Once you have started the program, simply type the shortcut listed on the left side of the table to copy the character on the right side of the table to your clipboard. Shortcodes the same length as the longest one will automatically be entered. To quit, use ^C
 
 Some of the default charfiles have hidden shortcuts for capital letters that are not shown on the table. Simply type a capital version of the shortcut key to access the capital version of the special character.
 
@@ -27,5 +27,5 @@ Fill it in, using the provided examples as a template. Hidden shortcuts go above
 
 ## License
 Charfile is GNU GPLv3 licensed, see COPYING for more information
+
 Charfile is written by [Armaan Bhojwani](https://armaan.bhojwani.org), [Email](mailto:3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me)
diff --git a/charsel b/charsel
index 5ee8b80da8e0cf683a20cf04c60077c33068aa87..d2e7525e0c246a9b4a4a165d024e169ce22c9d74 100755 (executable)
--- a/charsel
+++ b/charsel
@@ -19,7 +19,7 @@
 
 ########################################################################
 
-# Merge both global and local charfiles
+# Merge global and local charfiles
 CHARDIR=$HOME/.cache/charsel
 
 if [[ ! -d $CHARDIR ]]
@@ -39,17 +39,19 @@ then
 fi
 
 # Check for user inputs
-if [[ $1 == "list" \
-  || $1 == "-l" \
+if [[ $1 == "-l" \
   || $1 == "--list" ]]
 then
   echo "The following charfiles are installed:"
   ls $CHARDIR/charfiles
   exit 0
-elif [[ $1 == "help" \
-  || $1 == "-h" \
-  || $1 == "--help" \
-  || $# -ne 1 ]]
+elif [[ $1 == "-h" \
+  || $1 == "--help" ]]
+then
+  cat /usr/share/doc/charsel/usage
+  exit 0
+elif [[ $1 == "-d" \
+  || $1 == "--doc" ]]
 then
   cat /usr/share/doc/charsel/README.md
   exit 0
@@ -62,7 +64,7 @@ CHARFILE=$CHARDIR/charfiles/$1
 if [[ ! -f $CHARFILE ]]
 then
   echo "Please enter a valid charfile."
-  charsel list
+  charsel -l
   exit 1
 fi
 
@@ -83,11 +85,19 @@ do
   echo "*---------*---------------*"
   echo ""
 
-  cat $CHARFILE \
-    | sed -e '/^[ \t]*#/d' \
-    | grep -A 100 - \
-    | tail -n +2 \
-    | column -t -N input,output --output-separator ' | ' --separator ','
+  if [[ $2 == "--all" ]]
+  then
+    cat $CHARFILE \
+      | sed -e '/^[ \t]*#/d' \
+      | tail -n +2 \
+      | column -t -N input,output --output-separator ' | ' --separator ','
+  else
+    cat $CHARFILE \
+      | sed -e '/^[ \t]*#/d' \
+      | grep -A 100 - \
+      | tail -n +2 \
+      | column -t -N input,output --output-separator ' | ' --separator ','
+  fi
 
   echo ""
   echo "*-------------------------*"
diff --git a/usage b/usage
new file mode 100644 (file)
index 0000000..acf882b
--- /dev/null
+++ b/usage
@@ -0,0 +1,10 @@
+Usage: /usr/bin/charsel [OPTION]... [CHARFILE]...
+A simple terminal charachter selector
+  -h, --help      show this message
+  -l, --list      show installed charfiles
+  -d, --doc       show readme
+      --all       include hidden shortcodes
+
+Exit status:
+  0 if OK,
+  1 if error