]> git.armaanb.net Git - charsel.git/commitdiff
Minor changes
authorArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Fri, 16 Oct 2020 23:52:26 +0000 (19:52 -0400)
committerArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Fri, 16 Oct 2020 23:52:26 +0000 (19:52 -0400)
No functional changes

README.md
TODO.md [deleted file]
charsel

index 0040ba7496f3fb028eef629452565958164a18bc..7ee46b1c049c2f4fc7c28960e9a182b9970ffd49 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
 # CHARSEL
-A very simple bash script to make copying frequently used special characters to your clipboard easy.
+A simple bash script to make copying frequently used special characters to your clipboard easy.
 
 It uses a plain-text file known as a "charfile" to define shortcuts to special characters that are easy to access on the keyboard.
 
@@ -14,17 +14,16 @@ Run `make uninstall` as root to remove. Will not delete your personal charfiles
   * 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`.
+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`.
 
-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. If the charfile you used has multi-character shortcut keys, then you must hit enter after using a single letter shortcut. If the only shortcuts are single-letter, however, you can simply type the shortcut without clicking enter.
+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.
 
-The default charfiles all 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.
+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.
 
 ## Creating a charfile
 Make a new file in `~/.local/share/charsel/` or `/usr/share/charsel` with the name that you would like to use to call the charfile in the command.
 
-Fill it in, using the provided examples as a template. Hidden shortcuts go above the '---', lines can be commented out using a '#' at the start of the line
+Fill it in, using the provided examples as a template. Hidden shortcuts go above the '-', lines can be commented out using a '#' at the start of the line
 
 ## License
 Charfile is GNU GPLv3 licensed, see COPYING for more information
diff --git a/TODO.md b/TODO.md
deleted file mode 100644 (file)
index f07b912..0000000
--- a/TODO.md
+++ /dev/null
@@ -1,2 +0,0 @@
-- "Smart" shortcode length detection
-- Add purge option to makefile
diff --git a/charsel b/charsel
index adffd273bd12d2b3f3afc32e4b41dae8d36e2a01..1b7da87ffe83c5cadf88bcefc98f0a7c629a9229 100755 (executable)
--- a/charsel
+++ b/charsel
@@ -1,6 +1,22 @@
 #!/usr/bin/env bash
 
+# (C) Copyright Armaan Bhojwani, 2020
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 # Merge both global and local charfiles
+
 CHARDIR=~/.cache/charsel
 
 if [[ ! -d $CHARDIR ]]
@@ -32,19 +48,20 @@ fi
 # Define charfile path
 CHARFILE=$CHARDIR/charfiles/$1
 
+# Check if given charfile exists
 if [[ ! -f $CHARFILE ]]
 then
-  echo "Please enter a valid charfile. You can list installed charfiles with \`charsel list\`"
+  echo "Please enter a valid charfile."
+  charsel list
   exit 1
 fi
 
-# Define length of shortcut
+# Define length of shortcode
 LENGTH=$(cat $CHARFILE \
   | cut -f 1 -d ',' -s \
   | wc -L \
   | cut -b 1)
 
-# Clear screen
 clear
 
 # Main program
@@ -72,14 +89,17 @@ do
   read -p "| input shortcode:   " -N $LENGTH INPUT
 
   # This can definately be simplifed, but it works fine
+  # Finds line number of shortcode
   LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE \
     | grep -wn $INPUT \
     | cut -d : -f 1)
-
+  
+  # Outputs charachter selected above
   OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE \
     | head -$LINENUMBER \
     | tail +$LINENUMBER)
-
+  
+  # Check to see if the shortcode actually exists
   if [[ $(cut -f 1 -d ',' -s $CHARFILE \
     | grep -wnc $INPUT) == "0" ]]
   then
@@ -89,7 +109,6 @@ do
   # Copy output to clipboard
   echo $OUTPUT | xclip -selection clipboard
 
-  # Clear screen
   clear
 
 done