From 76db80f5cf647e9aa47cd1404e7acd5107166dfb Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Sat, 17 Oct 2020 18:52:49 -0400 Subject: [PATCH] added proper usage --- Makefile | 2 ++ README.md | 14 +++++++------- charsel | 36 +++++++++++++++++++++++------------- usage | 10 ++++++++++ 4 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 usage diff --git a/Makefile b/Makefile index d9ffea1..d34ff02 100644 --- 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/ diff --git a/README.md b/README.md index 7ee46b1..295998d 100644 --- 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 `, 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 5ee8b80..d2e7525 100755 --- 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 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 -- 2.39.2