1 # Copyright 2020 Armaan Bhojwani
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Merge both global and local charfiles
19 cp -R /usr/share/charsel/* $CHARDIR/
20 cp -R ~/.local/share/charsel/* $CHARDIR/
22 # Check if user provided an input
23 if [ $1 = "list" ]; then
24 echo "The following charfiles are installed"
27 elif [[ $1 = "help" || $1 = "-h" || $1 = "--help" || $# -ne 1 ]]; then
28 cat /usr/share/doc/charsel/README.md
35 # Define charfile path
36 CHARFILE=$CHARDIR/charfiles/$1
38 # Define length of shortcut
39 LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
47 # Put charfile into table, showing only the shortcuts below the divider in the charfile
48 cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ','
50 # Automatically enter input
53 # Navigate to the right characther
54 OUTPUT=$(grep $INPUT $CHARFILE | cut -f 2 -d ',' -s)
59 # Copy output to clipboard
60 echo $OUTPUT | xclip -selection clipboard