From a0ab9edae51a8ef6e0334691a7b905dbbac87835 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Wed, 16 Sep 2020 10:31:05 -0400 Subject: [PATCH] I think that this is a fully working thing now --- INSTALL.sh | 15 +++++++++++++++ README.md | 16 +++++++++++++--- charsel | 29 +++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100755 INSTALL.sh diff --git a/INSTALL.sh b/INSTALL.sh new file mode 100755 index 0000000..36dc18d --- /dev/null +++ b/INSTALL.sh @@ -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 diff --git a/README.md b/README.md index c4bd7c3..6ce415b 100644 --- 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 + +## 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 8113723..3961cf2 100755 --- 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 -- 2.39.2