X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=charsel;h=7938a1c251847e106e55ddad6a63fb33b6b75242;hb=d0ed470926adc3f7c4d94e3c91a353317654010a;hp=cef174685cf360ca8b4651ede1b25766573d420f;hpb=4b7ab17d3340b6b7440631cec87ea30ec29b0c35;p=charsel.git diff --git a/charsel b/charsel index cef1746..7938a1c 100755 --- a/charsel +++ b/charsel @@ -19,9 +19,7 @@ ######################################################################## -VERSION=2.0.7 - -# Environment variables +VERSION=2.0.8 # Define argument functions function usage() { @@ -34,7 +32,9 @@ A simple terminal character selector -h show this message -L show installed charfiles without the message -l show installed charfiles - -v print version + -n dont copy character to clipboard, avoids Xclip dependency + -V check for updates + -v print current version Exit status: 0 okay, @@ -44,6 +44,18 @@ Exit status: 4 other error" } +function version_check(){ + NEW_VERSION=$(curl -s https://codeberg.org/armaan/charsel/raw/branch/master/charsel \ + | grep VERSION= | tail -c +9) + if [[ $VERSION != $NEW_VERSION ]] + then + echo "an update is available" + else + echo "you are up to date" + fi + +} + CHARDIR=$HOME/.cache/charsel function list() { ls $CHARDIR/charfiles @@ -107,13 +119,23 @@ function validity() { } # Look for arguments -if [ $# -eq 0 ]; then - usage - exit 3 -fi -while getopts ":baLlchdv" arg +while getopts ":abcdhlLnvV" arg do case ${arg} in + a) + SHOWALL="true" + ;; + b) + COLOR="bw" + ;; + c) + validity + exit 0 + ;; + d) + readme + exit 0 + ;; h) usage exit 0 @@ -127,24 +149,17 @@ do list exit 0 ;; - d) - readme - exit 0 - ;; + n) + COPY="no" + ;; v) echo "charsel" $VERSION exit 0 ;; - c) - validity + V) + version_check exit 0 ;; - a) - SHOWALL="true" - ;; - b) - COLOR="bw" - ;; ?) echo "Invalid option" usage @@ -154,16 +169,24 @@ do done shift $((OPTIND-1)) +if [ $# -eq 0 ]; then + echo "Please enter a valid charfile, or use charsel -h for help." + charsel -l + exit 3 +fi # Redefine charfile and check file validity CHARFILE="$CHARDIR/charfiles/$1" existence validity # Dependency check -if [[ -x xclip ]] +if [[ ! $COPY == "no" ]] then - echo "Please install xclip." - exit 4 + if [[ -x xclip ]] + then + echo "Please install xclip." + exit 4 + fi fi if [[ $(echo $LANG | grep UTF-8) -ne 0 ]] @@ -242,7 +265,10 @@ do fi # Copy output to clipboard - echo -n $OUTPUT | xclip -selection clipboard + if [[ ! $COPY == "no" ]] + then + echo -n $OUTPUT | xclip -selection clipboard + fi clear fi