]> git.armaanb.net Git - charsel.git/commitdiff
New charfiles, added support for unlimited length shortcuts, new README, added motd...
authorArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Wed, 16 Sep 2020 20:26:41 +0000 (16:26 -0400)
committerArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Wed, 16 Sep 2020 20:26:41 +0000 (16:26 -0400)
INSTALL.sh
README.md
charfiles/german [new file with mode: 0644]
charfiles/greek [new file with mode: 0644]
charfiles/latin
charfiles/lithuanian [new file with mode: 0644]
charfiles/spanish [new file with mode: 0644]
charsel
motd [new file with mode: 0644]

index da2911b30fde0a48f3f76aabcf4f9ffbfe808e7e..d883b1475adc0ad76d648dd48f4aebb45797c3d1 100755 (executable)
@@ -5,13 +5,17 @@ chmod 777 /tmp/charsel/
 chmod +x charsel
 
 if [ `whoami` == root ]; then
-  mkdir -p /usr/share/charsel
-  cp charfiles/* /usr/share/charsel/
+  mkdir -p /usr/share/charsel/charfiles
+  cp charfiles/* /usr/share/charsel/charfiles/
+  mkdir /usr/share/doc/charsel
+  cp README.md /usr/share/doc/charsel/
+  cp motd /usr/share/charsel
   cp charsel /usr/bin/
   exit
 else
-  mkdir -p ~/.local/share/charsel
-  cp charfiles/* ~/.local/share/charsel/
+  mkdir -p ~/.local/share/charsel/charfiles
+  cp charfiles/* ~/.local/share/charsel/charfiles
+  cp motd ~/.local/share/charsel/
   cp charsel ~/.local/bin/
   exit
 fi
index 6ce415bf63f59fe0629b3a6bc02ff2a4f07f753b..9606ad8b630cb981e0aaee9aef9ea27466679f76 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,22 +1,27 @@
-# charsel
-A very simple comand line tool to make a shortcut to a special characther. 
+# CHARSEL
+A very simple shell script to make copying frequently used special characters to your clipboard easy.
 
-It takes the input of a charfile, then puts it into a table and waits for your input. Once you put in your shortcut key, it prints the special character then copies it to the clipboard.
+It uses a plain-text file known as a "charfile" to define shortcuts to special characters that are easy to access on the keyboard.
 
-A charfile is just two columns with the shortcut on the left, then a separator, then the special charachter to be copied.
+## Installation
+Running the INSTALL.sh script should work fine for most people
+If it is run as root or with sudo, the program and charfiles will be installed for all users. If it is run without elevated privileges, it will just be installed for the local user.
 
-## INSTALLATION
-Run the INSTALL.sh script
-If run as root, it will be installed globally, if run without root, it will be just instaled for the local user
-
-## DEPENDENCIES
-posix shell
+## Dependencies
+Posix shell
 util-linux
 xclip
+A terminal with UTF-8 encoding enabled
 
 ## USAGE
-charsel <charfile>
+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.
+
+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.
 
 ## CREATING A CHARFILE
-Make a new file in ~/.local/share/charsel/ with the name that you want to use to call the file in the command
-Fill it in, using the provided example as a template.
+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 '---'
diff --git a/charfiles/german b/charfiles/german
new file mode 100644 (file)
index 0000000..5140b40
--- /dev/null
@@ -0,0 +1,11 @@
+A Ä
+O Ö
+U Ü
+S ẞ
+---
+a ä
+o ö
+u ü
+s ß
+
+4 €
diff --git a/charfiles/greek b/charfiles/greek
new file mode 100644 (file)
index 0000000..f63a415
--- /dev/null
@@ -0,0 +1,49 @@
+A,Α
+B,Β
+G,Γ
+D,Δ
+E,Ε
+Z,Ζ
+H,Η
+TH,Θ
+I,Ι
+K,Κ
+L,Λ
+M,Μ
+N,Ν
+X,Ξ
+OO,Ο
+P,Π
+R,Ρ
+S,Σ
+T,Τ
+U,Υ
+PH,Φ
+CH,Χ
+PS,Ψ
+O,Ω
+---
+a,α
+b,β
+g,γ
+d,δ
+e,ε
+z,ζ
+h,η
+th,θ
+i,ι
+k,κ
+l,λ
+m,μ
+n,ν
+x,ξ
+oo,ο
+p,π
+r,ρ
+s,σ
+t,τ
+u,υ
+ph,φ
+ch,χ
+ps,ψ
+o,ω
index 892c5b15e23461958ba1889fb66da2aea12e6f62..04d581e61c22a1d55a811544aa18e9d75c3421e9 100644 (file)
@@ -1,13 +1,11 @@
-A Ā
-E Ē
-I Ī
-O Ō
-U Ū
-
-a ā
-e ē
-i ī
-o ō
-u ū
-
-
+A,Ā
+E,Ē
+I,Ī
+O,Ō
+U,Ū
+---
+a,ā
+e,ē
+i,ī
+o,ō
+u,ū
diff --git a/charfiles/lithuanian b/charfiles/lithuanian
new file mode 100644 (file)
index 0000000..60a0a1b
--- /dev/null
@@ -0,0 +1,21 @@
+A,Ą
+C,Č
+E,Ę
+W,Ė
+I,Į
+S,Š
+U,Ų
+Y,Ų
+Z,Ž
+---
+a,ą
+c,č
+e,ę
+w,ė
+i,į
+s,š
+u,ų
+y,ū
+z,ž
+
+4,€
diff --git a/charfiles/spanish b/charfiles/spanish
new file mode 100644 (file)
index 0000000..48bba03
--- /dev/null
@@ -0,0 +1,19 @@
+A,Á
+E,É
+I,Í
+N,Ñ
+O,Ó
+U,Ú,
+Y,Ü,
+---
+a,á
+e,é
+i,í
+o,ó
+u,ú
+y,ü
+n,ñ
+
+/,¿
+1,¡
+4,€
diff --git a/charsel b/charsel
index dc2564f54921231b4803486ff72d168389fc5650..b3dc78623b172d3f0aa75f1132c255167b97afce 100755 (executable)
--- a/charsel
+++ b/charsel
@@ -1,25 +1,41 @@
 #!/usr/bin/env sh
-
 # Merge both global and local charfiles
 CHARDIR=/tmp/charsel
-cp /usr/share/charsel/* $CHARDIR
-cp ~/.local/share/charsel/* $CHARDIR
-
-# Check if user provided a charfile
-[ -z "$1" ] && echo "No argument supplied"  && exit 1
+cp -R /usr/share/charsel/* $CHARDIR/
+cp -R ~/.local/share/* $CHARDIR/
 
 # Clear screen
 clear
 
+# Check if user provided an input
+[ -z "$1" ] && echo "No argument supplied"  && exit
+
+if [ $1 = "list" ]; then
+  echo "The following charfiles are installed"
+  ls $CHARDIR/charfiles
+  exit
+else
+
+# Define charfile
+CHARFILE=$CHARDIR/charfiles/$1
+
+# Define length of shortcut
+LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
+
+# MOTD
+cat /tmp/charsel/motd
+
+# Main program
 while :
 do
-  
-  # Put charfile into table
-  column -t $CHARDIR/$1 -N SHORT,CHAR -R SHORT,CHAR --output-separator ' | '
-  read -n 1 INPUT
+  # Put charfile into table, showing only the shortcuts below the divider in the charfile
+  cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t  --output-separator ' | ' --separator ','
+
+  # Automatically enter input
+  read -N $LENGTH INPUT
   
   # Navigate to the right characther
-  OUTPUT=$(grep $INPUT $CHARDIR/$1 | cut -c 3)
+  OUTPUT=$(grep $INPUT $CHARFILE | cut -f 2 -d ',' -s)
 
   # Clear screen
   clear
@@ -27,3 +43,5 @@ do
   # Copy output to clipboard
   echo $OUTPUT | xclip -selection clipboard
 done
+
+fi
diff --git a/motd b/motd
new file mode 100644 (file)
index 0000000..f95b67e
--- /dev/null
+++ b/motd
@@ -0,0 +1,2 @@
+WELCOME TO CHARSEL!
+FOR HELP, PLEASE REFER TO /usr/share/doc/charsel/README.md