#!/usr/bin/env bash
# Charsel - terminal character selector
-# Copyright Armaan Bhojwani 2020, MIT License. See the LICENSE file or
-# https://opensource.org/licenses/MIT for more information
-
-VERSION=2.0.8
+# Copyright Armaan Bhojwani 2020, MIT License
# Define argument functions
function usage() {
echo "Usage: /usr/bin/charsel [OPTION]... [CHARFILE]...
+
A simple terminal character selector
-a include hidden shortcodes
-b disable color support
-L show installed charfiles without the message
-l show installed charfiles
-n dont copy character to clipboard, avoids Xclip dependency
- -V check for updates
- -v print current version
Exit status:
0 okay,
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
n)
COPY="no"
;;
- v)
- echo "charsel" $VERSION
- exit 0
- ;;
- V)
- version_check
- exit 0
- ;;
?)
echo "Invalid option"
usage
charsel -l
exit 3
fi
+
# Redefine charfile and check file validity
CHARFILE="$CHARDIR/charfiles/$1"
existence
# Dependency check
if [[ $COPY == "no" ]]; then
- if [[ -x /usr/bin/xclip ]]; then
+ if [[ ! -x /usr/bin/xclip ]]; then
echo "Please install xclip."
exit 4
fi
bold=$(tput bold)
normal=$(tput sgr0)
-magenta=$(tput setaf 5)
-[[ $COLOR == bw ]] && magenta=$(tput setaf 7)
+highlight=$(tput setaf 5)
+[[ $COLOR == bw ]] && highlight=$(tput setaf 7)
white=$(tput setaf 7)
do
# Format output
echo "*---------*---------------*"
- echo "| ${bold}${magenta}CHARSEL${white}${normal} |" "$1"
+ echo "| ${bold}${highlight}CHARSEL${white}${normal} |" "$1"
echo "*---------*---------------*"
echo ""