VERSION=2.0.7
-# Environment variables
-
# 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
+ -c check charfile validity
+ -d show readme
-h show this message
- -l show installed charfiles
-L show installed charfiles without the message
- -d show readme
+ -l show installed charfiles
+ -n dont copy character to clipboard, avoids Xclip dependency
-v print version
- -c check charfile validity
- -a include hidden shortcodes
Exit status:
0 okay,
usage
exit 3
fi
-while getopts ":aLlchdv" arg
+while getopts ":abcdhlLnv" arg
do
case ${arg} in
+ a)
+ SHOWALL="true"
+ ;;
+ b)
+ COLOR="bw"
+ ;;
+ c)
+ validity
+ exit 0
+ ;;
+ d)
+ readme
+ exit 0
+ ;;
h)
usage
exit 0
list
exit 0
;;
- d)
- readme
- exit 0
- ;;
+ n)
+ COPY="no"
+ ;;
v)
echo "charsel" $VERSION
exit 0
;;
- c)
- validity
- exit 0
- ;;
- a)
- SHOWALL="true"
- ;;
?)
echo "Invalid option"
usage
validity
# Dependency check
-if [[ -x xclip ]]
+if [[ ! $COPY == "no" ]]
+then
+ if [[ -x xclip ]]
+ then
+ echo "Please install xclip."
+ exit 4
+ fi
+fi
+
+if [[ $(echo $LANG | grep UTF-8) -ne 0 ]]
then
- echo "Please install xclip."
+ echo "Please enable unicode support"
exit 4
fi
bold=$(tput bold)
normal=$(tput sgr0)
+if [[ $COLOR == bw ]]
+then
+ magenta=$(tput setaf 7)
+else
+ magenta=$(tput setaf 5)
+fi
+
+white=$(tput setaf 7)
+
# Main program
while true
do
# Format output
echo "*---------*---------------*"
- echo "| ${bold}CHARSEL${normal} |" $1
+ echo "| ${bold}${magenta}CHARSEL${white}${normal} |" $1
echo "*---------*---------------*"
echo ""
fi
# Copy output to clipboard
- echo -n $OUTPUT | xclip -selection clipboard
+ if [[ ! $COPY == "no" ]]
+ then
+ echo -n $OUTPUT | xclip -selection clipboard
+ fi
clear
fi