Skip to content

Instantly share code, notes, and snippets.

@atr000
Created October 4, 2010 15:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atr000/609829 to your computer and use it in GitHub Desktop.
Save atr000/609829 to your computer and use it in GitHub Desktop.
iching.sh - random iching cast
#!/bin/bash
# iching.sh
# casts an i ching
# use: ching [number]
# with number looks up that hexagram, otherwise casts
function cast {
l=0
until [ $l == 6 ]
do
i=0
k=0
until [ $i == 3 ]
do
j=`cat /dev/urandom | tr -dc '0-9' | fold -w 1 | head -1`
let j=j%2
if [ $j == 0 ]
then
j=2
else
j=3
fi
let i=i+1
let k=k+j
done
let k=k%2
if [ $k == 0 ]
then
echo -n ":"
else
echo -n "|"
fi
let l=l+1
done
echo
}
if [ "$1" ]
then
if [ "$1" -gt 0 ] && [ "$1" -lt 65 ]
then
if [ $SSH_TTY ]
then
lynx "http://www.afpc.asso.fr/wengu/wg/wengu.php?no=$1&l=Yijing"
else
open "http://www.afpc.asso.fr/wengu/wg/wengu.php?no=$1&l=Yijing"
fi
exit
fi
fi
hex=`cast`
echo $hex | sed 's/:/------ ------/g;s/|/---------------/g' | fold -w 15
cat $0 | grep $hex | awk '{ printf $1 ") ";for(i=3;i<=NF;i++) printf $i " "}'
echo
exit
01 |||||| Force (乾 qián) The Creative
02 :::::: Field (坤 kūn) The Receptive
03 |:::|: Sprouting (屯 chún) Difficulty at the Beginning
04 :|:::| Enveloping (蒙 méng) Youthful Folly
05 |||:|: Attending (需 xū) Waiting
06 :|:||| Arguing (訟 sòng) Conflict
07 :|:::: Leading (師 shī) The Army
08 ::::|: Grouping (比 bǐ) Holding Together
09 |||:|| Small Accumulating (小畜 xiǎo chù) Small Taming
10 ||:||| Treading (履 lǚ) Treading (Conduct)
11 |||::: Prevading (泰 tài) Peace
12 :::||| Obstruction (否 pǐ) Standstill
13 |:|||| Concording People (同人 tóng rén) Fellowship
14 ||||:| Great Possessing (大有 dà yǒu) Great Possession
15 ::|::: Humbling (謙 qiān) Modesty
16 :::|:: Providing-For (豫 yù) Enthusiasm
17 |::||: Following (隨 suí) Following
18 :||::| Corrupting (蠱 gǔ) Work on the Decayed
19 ||:::: Nearing (臨 lín) Approach
20 ::::|| Viewing (觀 guān) Contemplation
21 |::|:| Gnawing Bite (噬嗑 shì kè) Biting Through
22 |:|::| Adorning (賁 bì) Grace
23 :::::| Stripping (剝 bō) Splitting Apart
24 |::::: Returning (復 fù) Return
25 |::||| Without Embroiling (無妄 wú wàng) Innocence
26 |||::| Great Accumulating (大畜 dà chù) Great Taming
27 |::::| Swallowing (頤 yí) Mouth Corners
28 :||||: Great Exceeding (大過 dà guò) Great Preponderance
29 :|::|: Gorge (坎 kǎn) The Abysmal Water
30 |:||:| Radiance (離 lí) The Clinging
31 ::|||: Conjoining (咸 xián) Influence
32 :|||:: Persevering (恆 héng) Duration
33 ::|||| Retiring (遯 dùn) Retreat
34 ||||:: Great Invigorating (大壯 dà zhuàng) Great Power
35 :::|:| Prospering (晉 jìn) Progress
36 |:|::: Brightness Hiding (明夷 míng yí) Darkening of the Light
37 |:|:|| Dwelling People (家人 jiā rén) The Family
38 ||:|:| Polarising (睽 kuí) Opposition
39 ::|:|: Limping (蹇 jiǎn) Obstruction
40 :|:|:: Taking-Apart (解 xiè) Deliverance
41 ||:::| Diminishing (損 sǔn) Decrease
42 |:::|| Augmenting (益 yì) Increase
43 |||||: Parting (夬 guài) Breakthrough
44 :||||| Coupling (姤 gòu) Coming to Meet
45 :::||: Clustering (萃 cuì) Gathering Together
46 :||::: Ascending (升 shēng) Pushing Upward
47 :|:||: Confining (困 kùn) Oppression
48 :||:|: Welling (井 jǐng) The Well
49 :|||:| Skinning (革 gé) Revolution
50 |:|||: Holding (鼎 dǐng) The Cauldron
51 |::|:: Shake (震 zhèn) Arousing
52 ::|::| Bound (艮 gèn) The Keeping Still
53 ::|:|| Infiltrating (漸 jiàn) Development
54 ||:|:: Converting The Maiden (歸妹 guī mèi) The Marrying Maiden
55 |:||:: Abounding (豐 fēng) Abundance
56 ::||:| Sojourning (旅 lǚ) The Wanderer
57 :||:|| Ground (巽 xùn) The Gentle
58 ||:||: Open (兌 duì) The Joyous
59 :|::|| Dispersing (渙 huàn) Dispersion
60 ||::|: Articulating (節 jié) Limitation
61 ||::|| Centre Confirming (中孚 zhōng fú) Inner Truth
62 ::||:: Small Exceeding (小過 xiǎo guò) Small Preponderance
63 |:|:|: Already Fording (既濟 jì jì) After Completion
64 :|:|:| Not-Yet Fording (未濟 wèi jì) Before Completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment