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