3 # Merge both global and local charfiles
4 CHARDIR=~/.cache/charsel
9 elif [[! "$(ls -A $CHARDIR)"]]
11 cp -rf /usr/share/charsel/* $CHARDIR/
12 cp -rf ~/.local/share/charsel/* $CHARDIR/
15 # Check for user inputs
18 echo "The following charfiles are installed"
21 elif [[ $1 = "help" || $1 = "-h" || $1 = "--help" || $# -ne 1 ]]
23 cat /usr/share/doc/charsel/README.md
30 # Define charfile path
31 CHARFILE=$CHARDIR/charfiles/$1
33 # Define length of shortcut
34 LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
39 # Put charfile into table, showing only the shortcuts below the divider in the charfile
40 cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ','
42 # Automatically enter input
45 # This can definately be simplifed, but it works fine
46 LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -wn $INPUT | cut -d : -f 1)
47 OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER)
52 # Copy output to clipboard
53 echo $OUTPUT | xclip -selection clipboard