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 $HOME/.local/share/charsel/- $CHARDIR/
15 # Check for user inputs
20 echo "The following charfiles are installed"
23 elif [[ $1 == "help" \
28 cat /usr/share/doc/charsel/README.md
32 # Define charfile path
33 CHARFILE=$CHARDIR/charfiles/$1
35 if [[ ! -f $CHARFILE ]]
37 echo "Please enter a valid charfile. You can list installed charfiles with \`charsel list\`"
41 # Define length of shortcut
42 LENGTH=$(cat $CHARFILE \
43 | cut -f 1 -d ',' -s \
53 # Format charfile into table, showing only the shortcuts below the divider in the charfile
57 | column -t -N input,output --output-separator ' | ' --separator ','
59 echo "*-------------------------*"
60 echo "| previous shorcode:" $INPUT
61 echo "| previous output: " $OUTPUT
62 echo "*-------------------------*"
65 read -p "| input shortcode: " -N $LENGTH INPUT
67 # This can definately be simplifed, but it works fine
68 LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE \
71 OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE \
75 # Copy output to clipboard
76 echo $OUTPUT | xclip -selection clipboard