]> git.armaanb.net Git - charsel.git/commitdiff
I think that this is a fully working thing now
authorArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Wed, 16 Sep 2020 14:31:05 +0000 (10:31 -0400)
committerArmaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me>
Wed, 16 Sep 2020 14:31:05 +0000 (10:31 -0400)
INSTALL.sh [new file with mode: 0755]
README.md
charsel

diff --git a/INSTALL.sh b/INSTALL.sh
new file mode 100755 (executable)
index 0000000..36dc18d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/env sh
+
+if [ `whoami` == root ]; then
+  mkdir -p /usr/share/charsel
+  cp charfiles/* /usr/share/charsel/
+  chmod +x charsel
+  cp charsel /usr/bin/
+  exit
+else
+  mkdir -p ~/.local/share/charsel
+  cp charfiles/* ~/.local/share/charsel/
+  chmod +x charsel
+  cp charsel ~/.local/bin/
+  exit
+fi
index c4bd7c3842b81d8c4c95e4a5eab84b1e74be848a..6ce415bf63f59fe0629b3a6bc02ff2a4f07f753b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,7 +1,13 @@
 # charsel
 A very simple comand line tool to make a shortcut to a special characther. 
-It takes the input of a .char file, 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.
-A .char file is just two columns with the shortcut on the left, then a separator, then the special charachter to be copied.
+
+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.
+
+A charfile is just two columns with the shortcut on the left, then a separator, then the special charachter to be copied.
+
+## 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
@@ -9,4 +15,8 @@ util-linux
 xclip
 
 ## USAGE
-charselect.sh $charfile
+charsel <charfile>
+
+## 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.
diff --git a/charsel b/charsel
index 811372365b78d759b029ecd09fdc229870262246..3961cf2f38bd47bd8b9aa3e0f2938fa8591ea270 100755 (executable)
--- a/charsel
+++ b/charsel
@@ -1,11 +1,28 @@
 #!/usr/bin/env sh
 
-CHARDIR=~/.local/share/charsel
+# Merge both global and local charfiles
+mkdir ~/.cache/charsel/ &
+cp /usr/share/charsel/* ~/.cache/charsel/
+cp ~/.local/share/charsel/* ~/.cache/charsel/
+CHARDIR=~/.cache/charsel
 
-column -t $CHARDIR/$1 -N SHORT,CHAR -R SHORT,CHAR --output-separator '    |    '
-read INPUT
+# clear screen
+clear
 
-OUTPUT=$(grep $INPUT $CHARDIR/$1 | cut -c 3)
+while :
+do
+  
+  # Put charfile into table
+  column -t $CHARDIR/$1 -N SHORT,CHAR -R SHORT,CHAR --output-separator ' | '
+  read INPUT
+  
+  # Navigate to the right characther
+  OUTPUT=$(grep $INPUT $CHARDIR/$1 | cut -c 3)
 
-echo $OUTPUT
-echo $OUTPUT | xclip -selection clipboard
+  # Clear screen
+  clear
+
+  # Print output, and copy to clipboard
+  echo $OUTPUT
+  echo $OUTPUT | xclip -selection clipboard
+done