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
27 # Define charfile path
28 CHARFILE=$CHARDIR/charfiles/$1
30 if [[ ! -f $CHARFILE ]]
32 echo "Please enter a valid charfile. You can list installed charfiles with \`charsel list\`"
36 # Define length of shortcut
37 LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
45 # Format charfile into table, showing only the shortcuts below the divider in the charfile
46 cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t -N input,output --output-separator ' | ' --separator ','
50 echo "--------------------------"
51 echo "enter the input shortcode here:"
56 # This can definately be simplifed, but it works fine
57 LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -wn $INPUT | cut -d : -f 1)
58 OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER)
60 # Copy output to clipboard
61 echo $OUTPUT | xclip -selection clipboard