-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
chem.sh
executable file
·30 lines (23 loc) · 1.08 KB
/
chem.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env sh
######################################################################
# @author : Gavin Jaeger-Freeborn ([email protected])
# @file : chem.sh
# @created : Thu 01 Oct 2020 07:09:09 PM
#
# @description : A script that utilizes fzf, groff, and recutils
# To get information on a element in the periodic table.
######################################################################
fmt="A:box \"\fB{{Symbol}}\fP\" \"{{Name}}\" \"{{AtomicMass}}\" \"{{ElectronConfiguration}}\" wid 3 ht 4
B:box invis \"{{AtomicNumber}}\" at (A.w.x + 0.5, A.e.y)
C:box \"{{OxidationStates}}\" invis at ((A.e.x - 0.5), (A.n.y - 0.3))"
# Replace with where ever you placed the included chem.rec file
CHEMREC=$HOME/chem.rec
SYMBOL=$(recsel -C "$CHEMREC" -P "Symbol,Name" | fzf --preview \
"recsel -e ' ( Symbol = \"{}\" ) || ( Name = \"{}\" ) ' $CHEMREC")
format(){
echo .PS
recsel -e " ( Symbol = '$SYMBOL' ) || ( Name = '$SYMBOL' ) " "$CHEMREC" | recfmt "$fmt"
printf '\n.PE'
}
format | pic -Tascii | nroff | sed -e '/^$/d'
# vim: set tw=78 ts=2 et sw=2 sr: