+
+# Define length of shortcode
+LENGTH=$(cat $CHARFILE \
+ | cut -f 1 -d ',' -s \
+ | wc -L \
+ | cut -b 1)
+
+clear
+
+# Main program
+while true
+do
+ # Format output
+ echo "*---------*---------------*"
+ echo "| CHARSEL |" $1
+ echo "*---------*---------------*"
+ echo ""
+
+ 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 "*-------------------------*"
+ echo "| previous shorcode:" $INPUT
+ echo "| previous output: " $OUTPUT
+ echo "*-------------------------*"
+
+ # User input
+ read -p "| input shortcode: " -N $LENGTH INPUT
+
+ if [[ $INPUT == ";"* ]] # Semicolon exits
+ 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
+ echo $OUTPUT | xclip -selection clipboard
+
+ clear
+ fi
+done