2 # Merge both global and local charfiles
3 CHARDIR=~/.cache/charsel
5 if [[ ! "$(ls -A $CHARDIR)" || ! -d $CHARDIR ]]; then
7 cp -R /usr/share/charsel/* $CHARDIR/
8 cp -R ~/.local/share/charsel/* $CHARDIR/
11 # Check if user provided an input
12 if [ $1 = "list" ]; then
13 echo "The following charfiles are installed"
16 elif [[ $1 = "help" || $1 = "-h" || $1 = "--help" || $# -ne 1 ]]; then
17 cat /usr/share/doc/charsel/README.md
24 # Define charfile path
25 CHARFILE=$CHARDIR/charfiles/$1
27 # Define length of shortcut
28 LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
36 # Put charfile into table, showing only the shortcuts below the divider in the charfile
37 cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ','
39 # Automatically enter input
42 # Navigate to the right characther
43 LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -n $INPUT | cut -d : -f 1)
44 OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER)
48 # Copy output to clipboard
49 echo $OUTPUT | xclip -selection clipboard