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