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
18 CHARDIR=~/.cache/charsel
20 cp -R /usr/share/charsel/* $CHARDIR/
21 cp -R ~/.local/share/charsel/* $CHARDIR/
23 # Check if user provided an input
24 if [ $1 = "list" ]; then
25 echo "The following charfiles are installed"
28 elif [[ $1 = "help" || $1 = "-h" || $1 = "--help" || $# -ne 1 ]]; then
29 cat /usr/share/doc/charsel/README.md
36 # Define charfile path
37 CHARFILE=$CHARDIR/charfiles/$1
39 # Define length of shortcut
40 LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1)
48 # Put charfile into table, showing only the shortcuts below the divider in the charfile
49 cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ','
51 # Automatically enter input
54 # Navigate to the right characther
55 OUTPUT=$(grep $INPUT $CHARFILE | cut -f 2 -d ',' -s)
60 # Copy output to clipboard
61 echo $OUTPUT | xclip -selection clipboard