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" \
26 cat /usr/share/doc/charsel/README.md
30 # Define charfile path
31 CHARFILE=$CHARDIR/charfiles/$1
33 if [[ ! -f $CHARFILE ]]
35 echo "Please enter a valid charfile. You can list installed charfiles with \`charsel list\`"
39 # Define length of shortcut
40 LENGTH=$(cat $CHARFILE \
41 | cut -f 1 -d ',' -s \
51 # Format charfile into table, showing only the shortcuts below the divider in the charfile
55 | column -t -N input,output --output-separator ' | ' --separator ','
58 echo "--------------------------"
59 echo "previous shorcode:" $INPUT
60 echo "previous output: " $OUTPUT
61 echo "--------------------------"
64 read -p "input shortcode: " -N $LENGTH INPUT
66 # This can definately be simplifed, but it works fine
67 LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE \
70 OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE \
74 # Copy output to clipboard
75 echo $OUTPUT | xclip -selection clipboard