#!/usr/bin/env sh
-CHARDIR=~/.local/share/charsel
+# Merge both global and local charfiles
+mkdir ~/.cache/charsel/ &
+cp /usr/share/charsel/* ~/.cache/charsel/
+cp ~/.local/share/charsel/* ~/.cache/charsel/
+CHARDIR=~/.cache/charsel
-column -t $CHARDIR/$1 -N SHORT,CHAR -R SHORT,CHAR --output-separator ' | '
-read INPUT
+# clear screen
+clear
-OUTPUT=$(grep $INPUT $CHARDIR/$1 | cut -c 3)
+while :
+do
+
+ # Put charfile into table
+ column -t $CHARDIR/$1 -N SHORT,CHAR -R SHORT,CHAR --output-separator ' | '
+ read INPUT
+
+ # Navigate to the right characther
+ OUTPUT=$(grep $INPUT $CHARDIR/$1 | cut -c 3)
-echo $OUTPUT
-echo $OUTPUT | xclip -selection clipboard
+ # Clear screen
+ clear
+
+ # Print output, and copy to clipboard
+ echo $OUTPUT
+ echo $OUTPUT | xclip -selection clipboard
+done