+
+white=$(tput setaf 7)
+
+# Main program
+while true
+do
+ # Format output
+ echo "*---------*---------------*"
+ echo "| ${bold}${magenta}CHARSEL${white}${normal} |" $1
+ echo "*---------*---------------*"
+ echo ""
+
+ if [[ $SHOWALL == true ]]
+ 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 "*-------------------------*"
+ echo "| previous shorcode:" $INPUT
+ echo "| previous output: " $OUTPUT
+ echo "*-------------------------*"
+
+ # User input
+ read -p "| ${bold}input shortcode: ${normal} " -N $LENGTH INPUT
+
+ if [[ $INPUT == ";"* ]] # Semicolon exts
+ then
+ clear
+ exit 0
+ elif [[ $INPUT == " "* ]] # Spaces dont count
+ then
+ OUTPUT=""
+ clear
+ else
+ # Finds line number of shortcode
+ LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -wn $INPUT | cut -d : -f 1)
+
+ # Outputs character selected above
+ OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER)
+
+ # Check to see if the shortcode actually exists
+ if [[ $(cut -f 1 -d ',' -s $CHARFILE | grep -wnc $INPUT) == "0" ]]
+ then
+ OUTPUT=""
+ fi
+
+ # Copy output to clipboard
+ if [[ ! $COPY == "no" ]]
+ then
+ echo -n $OUTPUT | xclip -selection clipboard
+ fi
+
+ clear
+ fi
+done