.DEFAULT_GOAL := install
-.RECIPEPREFIX := >
install:
->chmod +x ./charsel
->mkdir -p /usr/share/charsel/charfiles/
->cp charfiles/* /usr/share/charsel/charfiles/
->cp shell-completions /usr/share/charsel/
->mkdir /usr/share/doc/charsel
->cp README.md /usr/share/doc/charsel/
->cp ./charsel /usr/bin/
+ chmod +x ./charsel
+ mkdir -p /usr/share/charsel/charfiles/
+ cp charfiles/* /usr/share/charsel/charfiles/
+ cp shell-completions /usr/share/charsel/
+ mkdir /usr/share/doc/charsel
+ cp README.md /usr/share/doc/charsel/
+ cp ./charsel /usr/bin/
uninstall:
->rm -rf /usr/share/charsel/
->rm -rf /usr/share/doc/charsel/
->rm -rf /usr/bin/charsel
+ rm -rf /usr/share/charsel/
+ rm -rf /usr/share/doc/charsel/
+ rm -rf /usr/bin/charsel
reinstall:
->rm -rf /usr/share/charsel/
->rm -rf /usr/share/doc/charsel/
->rm -rf /usr/bin/charsel
->chmod +x ./charsel
->mkdir -p /usr/share/charsel/charfiles/
->cp charfiles/* /usr/share/charsel/charfiles/
->cp shell-completions /usr/share/charsel/
->mkdir /usr/share/doc/charsel
->cp README.md /usr/share/doc/charsel/
->cp ./charsel /usr/bin/
+ make uninstall
+ make install
purge:
->rm -rf ${HOME}/.local/share/charsel/
->rm -rf ${HOME}/.cache/charsel/
+ rm -rf ${HOME}/.local/share/charsel/
+ rm -rf ${HOME}/.cache/charsel/
install-completions-bash:
->echo "source /usr/share/charsel/shell-completions" >> '${HOME}/.bashrc'
->echo "autoload bashcompinit ; bashcompinit ; source /usr/share/charsel/shell-completions" >> '${ZDOTDIR}/.zshrc'
+ echo "source /usr/share/charsel/shell-completions" >> '${HOME}/.bashrc'
+ echo "autoload bashcompinit ; bashcompinit ; source /usr/share/charsel/shell-completions" >> '${ZDOTDIR}/.zshrc'
-# CHARSEL
+# charsel
A simple bash script to make copying frequently used special characters to your clipboard easy.
It uses a plain-text file known as a "charfile" to define easy to reach shortcuts to special characters
## Installation
-- Run `make install` as root to install
-- Run `make uninstall` as root to remove. Will not delete your personal charfiles
+- Run `make` as root to install
+- Run `make uninstall` as root to remove
- Run `make purge` to remove charsel files from your home directory
- Run `make install-completions` to install the shell completions
* Bash
* Linux
* Xclip (using the -n flag bypasses this)
- * A terminal with UTF-8 encoding enabled (most desktop environment's default terminal will be fine)
+ * A terminal with UTF-8 encoding enabled (most default terminals will be fine)
## Usage
For argument usage, use `charsel -h`
Make a new file in `~/.local/share/charsel/charfiles/` or `/usr/share/charsel/charfiles/` with the name that you would like to use to call the charfile in the command.
Fill in your shortcodes, using the provided examples in `/usr/share/charsel/charfiles` as a template. There are just 4 rules to follow.
- 1. The pattern is "shortcode,output"
- 2. Hidden shortcuts go above the line with "---"
- 3. Lines can be commented out using a "#" at the start
- 4. Shortcodes may not contain ";" (semicolon) as that is used to quit the program
- 5. Shortcodes cannot start with - as that confuses grep
+ 1. The pattern used is "shortcode,output"
+ 2. Hidden shortcodes go above the line with "---"
+ 3. Lines can be commented out using a "#"
+ 4. Shortcodes may not contain a semicolon or a hyphen
## License
Copyright Armaan Bhojwani 2020, MIT License, see the LICENSE file for more information
2,√
a<,∠
0,°
-`,′
-``,″
90,⊥
||,∥
~=,≅
p,π
a,∝
00,∞
-<<,≪
->>,≫
s,∑
g,γ
-gr,φ
-te,⊗
-cr,†
-n,⋂
-u,⋃
-su,⊆
-ps,⊂
-ns,⊄
-ss,⊇
-ns,⊅
-sy,⊖
-be,∈
em,Ø
-no,¬
-im,⇒
-if,⇔
-fa,∀
-te,∃
-ne,∄
-tf,∴
-bc,∵
-ep,ε
-in,∫
-li,∮
-mu,μ
-
-
#!/usr/bin/env bash
# Charsel - terminal character selector
-# Copyright Armaan Bhojwani 2020, MIT License. See the LICENSE file or
-# https://opensource.org/licenses/MIT for more information
-
-VERSION=2.0.8
+# Copyright Armaan Bhojwani 2020, MIT License
# Define argument functions
function usage() {
echo "Usage: /usr/bin/charsel [OPTION]... [CHARFILE]...
+
A simple terminal character selector
-a include hidden shortcodes
-b disable color support
-L show installed charfiles without the message
-l show installed charfiles
-n dont copy character to clipboard, avoids Xclip dependency
- -V check for updates
- -v print current version
Exit status:
0 okay,
4 other error"
}
-function version_check(){
- NEW_VERSION=$(curl -s https://codeberg.org/armaan/charsel/raw/branch/master/charsel \
- | grep VERSION= | tail -c +9)
- if [[ $VERSION != "$NEW_VERSION" ]]; then
- echo "an update is available"
- else
- echo "you are up to date"
- fi
-
-}
-
CHARDIR=$HOME/.cache/charsel
function list() {
ls "$CHARDIR"/charfiles
n)
COPY="no"
;;
- v)
- echo "charsel" $VERSION
- exit 0
- ;;
- V)
- version_check
- exit 0
- ;;
?)
echo "Invalid option"
usage
charsel -l
exit 3
fi
+
# Redefine charfile and check file validity
CHARFILE="$CHARDIR/charfiles/$1"
existence
# Dependency check
if [[ $COPY == "no" ]]; then
- if [[ -x /usr/bin/xclip ]]; then
+ if [[ ! -x /usr/bin/xclip ]]; then
echo "Please install xclip."
exit 4
fi
bold=$(tput bold)
normal=$(tput sgr0)
-magenta=$(tput setaf 5)
-[[ $COLOR == bw ]] && magenta=$(tput setaf 7)
+highlight=$(tput setaf 5)
+[[ $COLOR == bw ]] && highlight=$(tput setaf 7)
white=$(tput setaf 7)
do
# Format output
echo "*---------*---------------*"
- echo "| ${bold}${magenta}CHARSEL${white}${normal} |" "$1"
+ echo "| ${bold}${highlight}CHARSEL${white}${normal} |" "$1"
echo "*---------*---------------*"
echo ""